user2026696
user2026696

Reputation: 3

javascript window.open failing to open in same browser window

I am trying to open a web page in the same window after validating user ID. The html/javascript code is:

 <script language="javascript">
function check(form)/*function to check userid & password*/
{
  if(form.loginID.value == "" && form.loginPass.value == "") {
    window.open("mform.html","_self"); 
}
else {
    alert("Error Password or Username")  
      }
     }
 </script> 
 </body>

If I use _self the browser just reloads original page. If I change it to _blank it opens a new window with the correct page loaded. I have tried this in Safari, firefox and chrome browsers with the same results.

Any assistance is appreciated.

Upvotes: 0

Views: 1812

Answers (1)

Yair Nevet
Yair Nevet

Reputation: 13003

window.open is used to open a new window.

Use window.location.href = 'mform.html' to navigating the other URL in the same window.

Upvotes: 1

Related Questions