Window.onbeforeunload in Firefox

Asked

Viewed 347 times

3

When using "window.onbeforeunload" in firefox, it returns only a generic message as per the image below:

inserir a descrição da imagem aqui

Is there any way I can customize this message in a "modal" in firefox?

  • 1

    The most you can do is put a simple custom message without formatting or anything (i.e. a string). Everything else is on account of the browser. In the past the sites abused, opening new popups just before they were closed, etc, so today the browsers only give a simple and standardized option, without much freedom to deviate from it.

  • 1

    In Chrome, IE, Safari and Opera, you specify a message like this: window.onbeforeunload = function() { return 'sua mensagem aqui'; }

1 answer

1


Unfortunately, nay it is possible to overwrite the default message in Firefox.

The event beforeunload uses an internal browser method to stop closing/browsing. In the function assigned to the event, you must return a string that will be added to the default browser message. This in all browsers except Firefox, which only displays its own message.

Event documentation on the Mozilla Developer Network: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload

Documentation in the MSDN: https://msdn.microsoft.com/en-us/library/ms536907(VS.85). aspx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.