samuel_lopez Posted November 11, 2015 Share Posted November 11, 2015 HI All, I have a problem on how to confirm page redirection..How can I pop up a message that will confirm user when he want to go to another page of my website. I used this code, but it's always pops up message even when user save any data.I want only specific links to be affected by this code. Please help me. <script language="JavaScript" type="text/javascript"> window.onbeforeunload = function(){ return 'Are you sure you want to leave?'; }; </script> THank you Quote Link to comment https://forums.phpfreaks.com/topic/299436-confirm-page-redirection-in-some-web-pages/ Share on other sites More sharing options...
scootstah Posted November 11, 2015 Share Posted November 11, 2015 You'd want to use a class on links that should have the confirm dialog, and then use Javascript click events to show it. See here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener https://developer.mozilla.org/en-US/docs/Web/Events/click Quote Link to comment https://forums.phpfreaks.com/topic/299436-confirm-page-redirection-in-some-web-pages/#findComment-1526196 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.