window.onbeforeunload = function() { return "Не желаете посетить наш сайт?"; } Displays standard only.
window.onbeforeunload = function() { return "Не желаете посетить наш сайт?"; } Displays standard only.
Everything goes to the point that it is impossible to do.
Previously, browsers displayed the returned text as popup text, and also had the ability to show blocking windows: alert, confirm, prompt
But since May 2011, the HTML5 specification has added that blocking window calls can be ignored by the browser in the onbeforeunload event .
In addition, most browsers have stopped paying attention to the return value and display standard text.
From proven browsers it works in IE and EDGE, it does not work in FireFox, Chrome.
The return function does not display text. It returns a string in this situation. To display text on the screen, you need to place it in the DOM. As an example: document.querySelector('body').innerHTML='не желаете ли посетить?'
Source: https://ru.stackoverflow.com/questions/566235/
All Articles