How to prevent javascript inside firefox from closing a window / tab?

I am debugging a website using firebug. The website opens a window, performs some operations and closes it. It makes me lose the whole history of the Firebug network. Is there a way to prevent javastript from closing the window after it is complete, other than changing the code?

+4
source share
2 answers

I have not tried to use it, but there are settings in FF that supposedly allow you to do what you want.

Type about: config in the url line and press enter. After warning, you will see a list of configuration options. Locate dom.allow_scripts_to_close_windows and set it to false.

+3
source

You can rewrite the open method, which adds the beforeunload event. Look at the annotated code + bookmarklet below:

the code:

 javascript:(function(w){ var o = w.open; /* Stores original `window.open` method */ w.open = function() { /* Catches all window.open calls*/ var x = o.apply(w, arguments); /* Calls original window.open */ /* Bind beforeunload event */ x.addEventListener('beforeunload',function(e){e.preventDefault()},true); return x; } })(window); 

Bookmarklet:

 javascript:(function(w){var o=w.open;w.open=function(){var x=o.apply(w,arguments);x.addEventListener('beforeunload',function(e){e.preventDefault()},true);return x;}})(window); 
+4
source

Source: https://habr.com/ru/post/1398470/


All Articles