window.open(url)不能在同一个选项卡中打开新的网页 [英] window.open(url) not opening new web page in the same tab

查看:198
本文介绍了window.open(url)不能在同一个选项卡中打开新的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

window.open(index.php); 不会在 标签中打开新页面,它将以 标签。



我试过 window.open(index.php,'_ self')

这是我的代码:

 $。ajax({
url:login.php,
type:'POST',
data:username =+ name +& amp ; password =+ pwd,
datatype:text,
async:false,
cache:true,
timeout:30000,
error:function() {
返回true;
},
成功:函数(msg){

if(msg ==Validated)
{
警报(msg);
window.open(index.php);
}
if(msg ==密码错误)
{
alert (msg);
location.reload();
}
}
});


解决方案代替 window.open 您应该使用 window.location =http:// ....


window.open("index.php"); does not open the new page in the same tab, it opens it in a new tab.

I tried window.open("index.php",'_self') as well which does not open the tab at all.

Here is my code :

$.ajax({
    url: "login.php",
    type: 'POST',
    data : "username="+name+"&password="+pwd ,
    datatype :"text",
    async: false, 
    cache: true,
    timeout: 30000,
    error: function() {
        return true;
    },
    success: function(msg) {                        

       if(msg == "Validated")
        {
            alert(msg);
            window.open("index.php");
        }
        if(msg=="Incorrect password")
        {
            alert(msg);
            location.reload();                         
        }    
    }
});

解决方案

Instead of window.open you should use window.location = "http://...."

这篇关于window.open(url)不能在同一个选项卡中打开新的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆