
Disable ''stay/leave page'' dialogues when trying to leave pages
[I use firefox on Mac, Windows, and Android, but the issue seems to effect me mostly on Mac and Windows) I'm just guessing this to be a browse issue. However I won't miond the post being moved to a more relevant sub-forum.
I keep arriving at this solution when searching for a solution to the increasing number of sites using the irritatingly abused stay/leave page question-dialogue box which pops up when i want to leave a page. The common solution appears to be https://userscripts.org/scripts/show/23865 However, when this page loads, I just get an empty box which looks like one of those ones which normally contain scripts to run or stop running certain things, or even to add or embed items etc.
When researching I often need to load lots of pages top go through. however, when i then need to close them all, i end up manually having to complete these irritating dialogies which are OBVIOUSLY really meant for pages where you may be filling in a form, or editing something, and perhaps have not completed filling it in. However, many sites irritatingly abuse this and just add the feature anyway. It just tells yiou they are dodgy rather than trustworthy. Any up-to-date advice as on July 2025? Any trusted new extensions/addons for this as with auto-cookie form-fillers perhaps?
All Replies (1)
Looks like that site went offline years ago and someone else bought the domain.
According to the Wayback Machine (please support), the code was:
// ==UserScript== // @name BlockUnloadEvents // @namespace http://theaceoffire.8k.com/STOPTHEMADDNESS // @description This stops ANY AND ALL javascript that stops you from leaving a page. Inspired by this greasemonky script: http://userscripts.org/scripts/show/20781 // @include * // ==/UserScript== (function() { unsafeWindow.onbeforeunload = null; unsafeWindow.onunload = null; })();
But actually, you can toggle a Firefox preference if you want to block ALL "onbeforeunload" dialogs. I'll describe how in a second. Keep in mind, though, that this will prevent the warning on sites where you might not want to lose your work; there are no exceptions. An add-on or user script would be needed to manage exceptions (in the above example, by adding "// @exclude" lines.
(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.
More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future.
(2) In the search box in the page, type or paste beforeunload and pause while the list is filtered. Firefox should show 4 preferences.
(3) Double-click the dom.disable_beforeunload preference to switch the value from false to true if you need to disable this globally
When you are done visiting untrustworthy sites, you could return to your about:config tag and toggle/reset it back to true.