window.open("index.php");
不会在 same 选项卡中打开新页面,而是在 new 中打开它em> 选项卡。
我也尝试了 window.open("index.php",'_self')
,它根本没有打开标签页。
这是我的代码:
$.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();
}
}
});
最佳答案
你应该使用 window.location = "http://...."而不是
window.open
关于javascript - window.open(url) 不在同一选项卡中打开新网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16015459/