onpagehide Event in JavaScript
onpagehide Event in JavaScript
The onpagehide event is used to occur when user is navigating away from webpage. It is used instead of onunload event because onunload event does not cached the web page. We can navigate away from page in several different ways. These are:-
- refreshing
- form submitting
- browser closing
- link clicking
For your Information:-
The persisted property is a read-only property that returns a Boolean value that indicates if webpage is loaded directly from server or is cached when an onpageshow or onpagehide event occurs.
Syntax:-
Its syntax is:- < anyElement onpagehide="my_script" > OR object.onpagehide= function(){my_script} OR object.addEventListener("pagehide", my_script)