cliftonbazaar Posted January 17, 2011 Share Posted January 17, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/224661-confirm-box-not-redirecting-user/ Share on other sites More sharing options...
haku Posted January 17, 2011 Share Posted January 17, 2011 Try this: 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"; } return false ; } Quote Link to comment https://forums.phpfreaks.com/topic/224661-confirm-box-not-redirecting-user/#findComment-1160504 Share on other sites More sharing options...
cliftonbazaar Posted January 17, 2011 Author Share Posted January 17, 2011 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 :'( Quote Link to comment https://forums.phpfreaks.com/topic/224661-confirm-box-not-redirecting-user/#findComment-1160624 Share on other sites More sharing options...
cliftonbazaar Posted January 17, 2011 Author Share Posted January 17, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/224661-confirm-box-not-redirecting-user/#findComment-1160627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.