Jump to content

Confirm box not redirecting user


cliftonbazaar

Recommended Posts

Below is my php code that successfully calls the Javascript function (Which is located in confim.js).

echo "<BR><input type=submit value='SURRENDER' onClick='confirmSurrender()'>";  //Surrender if available

 

The problem is that the following code will not redirect the user to the proper page, to test the code I directed the user to Google but no matter how many times I click 'ok' I don't goto Google.  Next test was to put the alert box there to see if the function was working, the alert does come up but when I click on 'ok' it still doesn't send me to Google :(

function confirmSurrender()
  {
var answer=confirm("Are you sure you wish to surrender?");
if(answer) {
          alert("Does this actually work?")
  window.location = "http://www.google.com";
}
else {
  return false ;
}
  }

 

I am testing on Firefox 3.6 and have not tested on any other browser.

Link to comment
https://forums.phpfreaks.com/topic/224661-confirm-box-not-redirecting-user/
Share on other sites

Sorry but it doesn't work :(  I have also checked this under I.E 8.0

 

Have shrunk the code down to

function confirmSurrender()
  {
var answer=confirm("Are you sure you wish to surrender?");
if(answer)  window.location = "http://www.google.com";
return false;
  }

but it still doesn't redirect to google  :'(

In case someone in the future reads this -

Line in the PHP code was wrong - input type should of been 'Button'

 echo "<BR><input type='button' value='SURRENDER' onClick='confirmSurrender()'>";  //Surrender if available

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.