【发布时间】:2013-04-07 14:00:49
【问题描述】:
window.open("index.php"); 不会在 same 选项卡中打开新页面,而是在 新 选项卡中打开它。
我也试过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.open()的全部意义——打开一个新窗口。如果您想更新当前标签,只需将window.location.href设置为您的 URL。 -
我试过这个.....window.location.href 因为某些原因对我不起作用.....stackoverflow.com/questions/16002938/…
-
将
window.location.href设置为新值对每个人都有效。
标签: javascript jquery html window