Navigate away.

Subscribe to Navigate away. 9 posts, 4 voices

 
`Mods Scriptwright

I wanted to add a snippet that if you try to navigate away from the page (ie: clicking on link, closing tab) a confirm box would pop up. If you click ok it would continue to do what you told the browser to do or if you click cancel it would would not do the action. I tired to do a few things but someone told me that window.onbeforeunload only worked on IE.

An example is like meebo.com... I tired shifting trough there javascript but it is a mess. @_@

Thanks~

 
Mikado Scriptwright

Maybe window.onunload?

 
`Mods Scriptwright

Nope, "COMPONENT NOT AVAILABLE"

 
Mikado Scriptwright

It turned out easy:
document.body.setAttribute('onbeforeunload', 'return false;');
(Inspired by this example)

 
`Mods Scriptwright

Hey ass whole, you cold of warned me that would of taking over firefox. I just lost a good session.. and I couldn't just restore it since that page would open.

Or at least told me to disable javascript.

 
`Mods Scriptwright

Well the concept works neither the less. =p

 
Mikado Scriptwright

Since you got the code, what could be easier than typing javascript:void(document.body.setAttribute('onbeforeunload',null));? Blame yourself.

 
gollum Scriptwright

Real helpful AND a bit late for any js innocent who stumbles across your malicious link. /end sarcasm

 
Osias User

people,. use the extension "noscript"