Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.