A
A
Arthur Koch2012-06-14 14:51:49
JavaScript
Arthur Koch, 2012-06-14 14:51:49

Closing tab/browser or save our docks?

There is a web interface with which you have to work with data for a long time. Data is saved by clicking. Autosave doesn't work for certain reasons. How, when closing the browser / tab, to display a message that they say “Have you saved the data on this page?”.

I remember that in the old JS textbooks there were a lot of such examples. On the forums they wrote that it was not necessary to do this (at least on ordinary sites). But now I can’t find an example of how to implement this.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
V
Vitaliy Petrychuk, 2012-06-14
@dudeonthehorse

Use window.onbeforeunload

M
max_rip, 2012-06-14
@max_rip

For the opera, try it, I don’t remember what exactly, but somehow I struggled.
And then I just needed to send an event that the tab was closed, but most likely you can’t stop it.

if(window.opera){
  document.body.addEventListener('_close', ajaxUnload(), false);
  history.navigationMode = 'compatible';
  window.onunload =ajaxUnload;
}

K
Keyten, 2012-06-14
@Keyten

But what about document.body.onunload?

W
WEBIVAN, 2012-06-14
@WEBIVAN

window.onclose?

H
Hungry_Hunter, 2012-06-14
@Hungry_Hunter

Opera does not support this type of event. Closing a tab or browser is not tracked in Opera.

K
Keyten, 2012-09-09
@Keyten

You can confirm-ohm to suspend the closure. Those. ask: do you really need to close the page?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question