Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

how can i disable the message "leave page / stay on page"

more options

How can i disable the message "leave page / stay on page" please explain step by step if if it involved inserting java script.

Thanks

How can i disable the message "leave page / stay on page" please explain step by step if if it involved inserting java script. Thanks

Chosen solution

Installing this Greasemonkey script should help: https://userscripts.org/scripts/show/23865

(Be aware that this could break some sites, and isn't approved/vetted by Mozilla in any way shape or form.)

Read this answer in context 👍 3

All Replies (7)

more options

Chosen Solution

Installing this Greasemonkey script should help: https://userscripts.org/scripts/show/23865

(Be aware that this could break some sites, and isn't approved/vetted by Mozilla in any way shape or form.)

more options

Isn't there a way to disable the prompt in Firefox's configuration? I don't want to add a script to Firefox that might "break" some pages.

more options

You could consider to use a bookmarklet to disable those events if it happens in specific condition and only on some known web pages.

  • javascript:void(window.onbeforeunload = null);void(window.onunload = null);
more options

Allowing pages to watch for and respond to those two standard JavaScript events (unload, beforeunload) can be useful in some cases. For example, a site where you are editing a post or message can remind you that you're about to lose some work when you want to leave the page.

But yes, some sites do abuse these events to try to trap you into doing something...

I'm not aware of any built-in setting that will disable pages from watching for and responding to those two standard JavaScript events (unload, beforeunload).

The NoScript extension will block ALL scripts from running on a site, but you do have to train it to trust sites you use where you DO want scripts to run, so this may be too much hassle if you only want to use it for this one purpose. (Coincidentally, it blocks a lot of ads and tracking scripts, so it has other attractions.)

Wish I could think of something better.

more options

Thanks for trying to help.

more options

These three userscripts are along the same lines as the one link to above:

None of the four scripts has any mechanism for site exceptions built into it, but you can make exceptions using Greasemonkey's user settings tab. You do that using the script's Options dialog. You can do that from the Add-ons page, User Scripts category. Either:

  • Monkey toolbar button > Manage User Scripts
  • Ctrl+Shift+a (Mac: Command+Alt+a) > User Scripts
  • orange Firefox button (or Tools menu) > Add-ons > User Scripts

Then click the Options button for the relevant script. On the User Settings tab, in the Excluded Pages box, you can enter the site that you want to carve out of the script. Note that in order to match all pages on the site, you need to use the wildcard character (*) as shown in the attached screen shot.