N
N
nezzard2017-01-14 20:13:51
Windows
nezzard, 2017-01-14 20:13:51

How to prevent the application from closing?

Good afternoon, tell me if there is a solution?
Need to prevent the browser in which the tab is open from closing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iBird Rose, 2017-01-14
@iiiBird

prevent closing the browser - no way. but you can display an alert when you try to close the tab:

window.onunload = function()
{
    return confirm('Вы хотите покинуть сайт?')
}
window.onbeforeunload = function(){
    return confirm('Точно хотите выйти?');
}

but even so, some browsers ignore it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question