3
Does anyone know how I would display a <div>
which is hidden when the user clicks the close button on the browser window?
3
Does anyone know how I would display a <div>
which is hidden when the user clicks the close button on the browser window?
1
In case you could run a javascript that displays an Alert or modal for this, eg:
<script>
window.onbeforeunload = function (event) {
var message = 'Você tem certeza que deseja sair?';
if (typeof event == 'undefined') {
event = window.event;
}
if (event) {
event.returnValue = message;
}
return message;
}
</script>
Documentation about the beforeunload event.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
I need to display a custom window, so I thought of a <div>
make the modal is quiet, the problem is to call it when click on the close button of the browser and only display the modal without closing the browser
there are some limitations that one can perform in the beforeunload, have to see if it allows to run a modal within it.
Staff thank you very much all!
@Munirbaarini follows event documentation https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
Thank you very much Jefferson!
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.
I did the test and the page displayed the div and closes, it would be possible not to close the page, but only to display the div?
– Munir Baarini
no, unless you create a browser plugin that does this.
– RFL
What is done is different, show before closing, when leaving with the mouse at the top of the screen. By the way, a very boring thing. (If interested, do a search, this has already been asked on the site).
– Bacco
I agree, but I need to display a div with a message saying that the user has not filled in all the data if he really wants to close the browser.
– Munir Baarini
I believe you could display an Alert or something before leaving
– Jeferson Almeida
So, it is easier to warn you when leaving with the mouse, because it gives more time to see. Maybe for your case it is the case to ask if it confirms to close. And this already has answer on the site too, how to ask for confirmation.
– Bacco
It would be very nice, could guide me how to produce?
– Munir Baarini
Here: http://answall.com/questions/62571/70
– Bacco
She also has: http://answall.com/questions/71128/70
– Bacco
I posted a solution, but as @Bacco reported, there are already several solutions to this problem in Sopt or OS
– Jeferson Almeida
@Munirbaarini I know you have already been pointed out, but I would like you to take a look at my answer http://answall.com/a/113155/3635, in which I explain how unonload/beforeunload actually work and how facebook-like websites do to display a "div".
– Guilherme Nascimento
I understand William, so it is not possible to customize the modal.
– Munir Baarini