html tutorial - onpagehide Attribute in HTML - html5 - html code - html form




  • The onpagehide attribute occurs when the user is redirecting away from a webpage.
  • The onpagehide event is frequently used instead of the onunload event, as the onunload event causes the page is not being cached.

Syntax for onpagehide attribute in HTML:

<body onpagehide="script">

Applies to:

Elements Attribute
<body> onpagehide

Attributes Values of onpagehide attribute in HTML:

Value Description
Script The script can run on onpagehide

Sample coding for onpagehide attribute in HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy onpagehide Attribute</title>
    </head>
    <body onpagehide="onPageHide()">
        <h1><Wikitechy onpagehide Attribute></h1>    
        <script>
            function onPageHide() {
                alert ("Thank you, Please Visit again.");
            }
        </script>
    </body>
</html>

Code Explanation for onpagehide attribute in HTML:

onpagehide Attribute Code Explanation

  1. The onpagehide attribute calls the JavaScript Function onPageHide() and occurs when a user navigates away from the page.
  2. The JavaScript Function onPageHide() display an alert box with the message ”Thank you, Please Visit again.”.

Browser Support for onpagehide attribute in HTML:

Yes 11.0 Yes 5.0 Yes

Related Searches to onpagehide attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×