I
I
ilovemaryjane2018-11-19 00:38:29
JavaScript
ilovemaryjane, 2018-11-19 00:38:29

Window close confirmation in Chrome?

Everyone knows the nasty alert window when you close the "Are you sure that ...?"
Let's not talk about the ethics of this action (this feature also has normal applications: for example, a warning for unsaved data in the text input editor), I wonder how some sites still manage to bypass the blocking of this window by Chrome? 'Cause it doesn't work

window.onbeforeunload = function(e) {
        return 'Dialog text here.';
      }

or
window.addEventListener("beforeunload", function (event) {
        alert("Hello! I am an alert box!!")
        event.preventDefault()
      })

How do they do it then? Quite accurately, this warning will appear periodically on all pirated resources. How do they get around?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-11-19
@Stalker_RED

Who told you they don't work?
test (press ctrl+U in browser to view source)
Documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question