繁体   English   中英

通过 javascript 在同一选项卡中打开页面 html

[英]Open page in the same tab html via javascript

我正在尝试编写一个代码来匹配用户名和密码。 如果两者都正确,则必须将其重定向到新页面,如果错误,则必须发出警告消息。 当密码正确并且单击提交时,它会在新选项卡中打开成功消息,我希望它显示在同一选项卡中。

    function redirectPage(form) {
    if (form.uname.value == 'test' && form.uname.value == 'test') {
       window.open('login.html');
    } else {
      alert("Wrong Credentials, Try again")
    } 

附言

       window.open('login.html','_self');

不工作

用这个

window.location.replace("login.html");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM