onbeforeunload load in javascript help
I have this code in javascript below:
function ExitPage(){return 'Wait!';}
<body onbeforeunload="return ExitPage();">
I would like to run some codes when the user clicks on the "cancel" button. How will I accomplish this?
Any suggestion would be g开发者_运维百科reatly appreciated.
Thanks
This is not possible. At least not in a safe way - the only think you could do is starting a timer in the onbeforeunload
handler that runs for e.g. 10 seconds. If the page is still open after this time this timer then runs your code.
精彩评论