X
Bakstelėkite čia, kad pereitumėte į mobiliąją šios svetainės versiją.

Pagalbos forumas

no way to disable the javascript window.onbeforeunload()

Paskelbta

Firefox has given the options for the user to control how certain javascript functions can be used. I came across a horrible use of window.onbeforeunload() which keeps firefox from closing a tab, and therefore also quiting. A manual kill is required to close a page with the following code: (just open in firefox to test)

<title>test</title><script type="text/javascript">window.onbeforeunload=function(){return 'PRESS ESCAPE OR CLOSE THIS ALERT\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';}</script>

It would be great if I could disable this javascript code, just like I can with window move/resize, raise/lower, hide statusbar, etc..

Firefox has given the options for the user to control how certain javascript functions can be used. I came across a horrible use of window.onbeforeunload() which keeps firefox from closing a tab, and therefore also quiting. A manual kill is required to close a page with the following code: (just open in firefox to test) <html> <head> <html><title>test</title><head><script type='text/javascript'>window.onbeforeunload=function(){return 'PRESS ESCAPE OR CLOSE THIS ALERT\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';}</script></body></html> It would be great if I could disable this javascript code, just like I can with window move/resize, raise/lower, hide statusbar, etc..

Papildomi duomenys apie sistemą

Tai nutiko

Kiekvieną kartą, atveriant „Firefox“

Įdiegti papildiniai

  • The IcedTea NPR Web Browser Plugin (using IcedTea6 1.8.1 (6b18-1.8.1-0ubuntu1)) executes Java applets.
  • Shockwave Flash 10.1 r85

Application

  • User Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.11) Gecko/20101013 Ubuntu/10.04 (lucid) Firefox/3.6.11

More Information

jhathaway Sprendimų: 0 Atsakymų: 2

Naudingas atsakymas

I have the same problem. This script attaches to random web pages, then will not allow me to close the page. I have to use Task Manager to kill Firefox.

window.onbeforeunload=function(){return 'PRESS ESCAPE OR CLOSE THIS ALERT\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\

I have the same problem. This script attaches to random web pages, then will not allow me to close the page. I have to use Task Manager to kill Firefox. window.onbeforeunload=function(){return 'PRESS ESCAPE OR CLOSE THIS ALERT\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
jhathaway Sprendimų: 0 Atsakymų: 2

Same reply as above.

Same reply as above.

Modified by jhathaway

cor-el
  • Top 10 Contributor
  • Moderator
Sprendimų: 17763 Atsakymų: 160635

You can either disable JavaScript temporarily (Tools > Options > Content) or use a bookmarklet like this:

javascript:void(window.onbeforeunload=null);
You can either disable JavaScript temporarily (Tools > Options > Content) or use a bookmarklet like this: <pre><nowiki>javascript:void(window.onbeforeunload=null);</nowiki></pre>
awack1388 Sprendimų: 0 Atsakymų: 1

The only solution I've found that works correctly cross-browser is javascript:window.onbeforeunload=null;

The only solution I've found that works correctly cross-browser is javascript:window.onbeforeunload=null;
alecail Sprendimų: 0 Atsakymų: 1

First, install GreaseMonkey: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

Then, create a new user script for all pages, or for the specific website; the script itself is very simple, it's just this line:

window.onbeforeunload=null;


It's just overriding the annoying function called at the time the page is closed, with an empty function. That's all. In some cases, it may not work if some script inside the page is modifying the DOM after the page is loaded. Have fun!

First, install GreaseMonkey: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ Then, create a new user script for all pages, or for the specific website; the script itself is very simple, it's just this line: window.onbeforeunload=null; It's just overriding the annoying function called at the time the page is closed, with an empty function. That's all. In some cases, it may not work if some script inside the page is modifying the DOM after the page is loaded. Have fun!