F
F
Faig Alizale2017-08-13 21:25:47
JavaScript
Faig Alizale, 2017-08-13 21:25:47

How to display a message when closing a bookmark in JavaScript?

Hello, I want to make it so that when you close the browser window with our site or something else, when you leave our site, display a message
How to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsbeats, 2017-08-13
@faiqalizade

window.onbeforeunload = function () {
  return "Точно хочешь закрыть страницу?";
}

But:
1) Such sites are infuriating
2) In different browsers, the message will look different, browsers also add their own additional text, stating that the message is displayed by the site, and not by the browser.

S
Stalker_RED, 2017-08-13
@Stalker_RED

You can display the table using onbeforeunload
Example
Doesn't work everywhere. And almost none of the modern browsers allows you to change the message.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question