You can also use, object.onpagehide=function(){script};"/> You can also use, object.onpagehide=function(){script};">

Home >Web Front-end >HTML Tutorial >Execute a script when the user leaves the HTML page?

Execute a script when the user leaves the HTML page?

王林
王林forward
2023-08-28 22:25:031269browse

Execute a script when the user leaves the HTML page?

The onpagehide attribute fires when the user navigates from the page. Navigation occurs when a user clicks a link, closes a browser tab, submits a form, etc.

To execute it, try -

<p onpagehide = "myScript">

You can also use,

object.onpagehide = function(){script};

The above is the detailed content of Execute a script when the user leaves the HTML page?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete