-3

In the following code when the if condition is true then it should go to google.com but is isn't. I wanted the window to go to google.com as the ok in the alert box is pressed why this isn't working? What is the best way to do it?

 if(("admin"===userid)&&("admin"===psw))
       {   
           window.alert("Logged in Successfully!!!");
           window.location.href="https://www.google.co.in";
           x=x+1;
        }
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • http://stackoverflow.com/questions/7077770/window-location-href-and-window-open-methods-in-javascript – Sumedh Mar 02 '15 at 17:42
  • @Sumedh what is the relation of your link with the question(besides the `window.location.href`) ? – DontVoteMeDown Mar 02 '15 at 17:43
  • The link describes two ways to open a url, one of which is used by OP.Also, the answer there,explains in detail about each of the two methods. – Sumedh Mar 02 '15 at 17:47

1 Answers1

0
if(("admin"===userid)&&("admin"===psw)){
    var r = confirm("Logged in Successfully!!!");
    if( r == true ){
        window.location.href="https://www.google.co.in";
        x=x+1;

    } else {
        // non redirect stuff here 
    }       
}

Research: jQuery: how to open a dialog window (Answer 2)

Community
  • 1
  • 1
Mat Forsberg
  • 454
  • 2
  • 10