How do you call that code that when the client leaves the page pops up with some offer or asking the client not to leave?
Can anyone give an example of some code?
How do you call that code that when the client leaves the page pops up with some offer or asking the client not to leave?
Can anyone give an example of some code?
If it is called "Confirmation", browsers implement the global method confirm(mensagem)
.
This method for page execution, that is, is synchronous, after you receive the response from the client that the page will continue to run, it returns true
or false
(and maybe null
). / p>
The "beforeunload" event allows the confirm
method to display this type of confirmation before exiting the page if it is set to pure confirm
, without using DOM add event methods:
self.onbeforeunload = confirm;
That is, you can not choose your own message when you leave the page! Not even with Function#bind
(because it creates a new function with it).
I think you're referring to alert("mensagem")
of Javascript. If so, you can find examples and uses here.