acidpaul
acidpaul

Reputation: 165

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 greatly appreciated.

Thanks

Upvotes: 1

Views: 176

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318808

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.

Upvotes: 2

Related Questions