I am using Firefox to automatically navigate and capture screenshots from various websites. Some of these websites use the onbeforeunload event to capture a user's attention before leaving a page.

Right now, this prevents my script from navigating to the next URL and I have to run the following JS to redefine the event to do nothing, like below:

window.onbeforeunload = function () {};

I'd like to put this logic in the browser and not to deal with a bunch of edge-cases in my code. Ideally keeping Javascript enabled, whilst blocking this event (possibly others) on all pages the browser visits.

Is this possible through a known extension or via Firefox profile settings?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.