From c1e4507c8e27279c52338d94340dfb63fb972c6f Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Wed, 20 Dec 2017 20:31:18 +0300 Subject: [PATCH] minor --- .../10-onload-ondomcontentloaded/article.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/2-ui/3-event-details/10-onload-ondomcontentloaded/article.md b/2-ui/3-event-details/10-onload-ondomcontentloaded/article.md index 277b70ef..11305212 100644 --- a/2-ui/3-event-details/10-onload-ondomcontentloaded/article.md +++ b/2-ui/3-event-details/10-onload-ondomcontentloaded/article.md @@ -128,28 +128,24 @@ For that we should use another event -- `onbeforeunload`. ## window.onbeforeunload [#window.onbeforeunload] -If a visitor initiated leaving the page or tries to close the window, the `beforeunload` handler can ask for additional confirmation. +If a visitor initiated navigation away from the page or tries to close the window, the `beforeunload` handler asks for additional confirmation. -It needs to return the string with the question. The browser will show it. +It may return a string with the question. Historically browsers used to show it, but as of now only some of them do. That's because certain webmasters abused this event handler, to protect the visitor from potentially misleading and hackish messages. -For instance: +You can try it by running this code and then reloading the page. -```js +```js run window.onbeforeunload = function() { return "There are unsaved changes. Leave now?"; }; ``` ```online -Click on the button in `