
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM PopStateEvent Object
The HTML DOM popStateEvent object is an event handler for the popstate event which occurs when window’s history changes.
Property of PopStateEvent
Property | Explanation |
---|---|
state | It returns an object that represents a copy of the history entries. |
Example
Let us see an example of HTML DOM popStateEvent Object −
<!DOCTYPE html> <html> <head> <style> html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } p{ font-size:1.2rem; } .btn{ background:#0197F6; border:none; height:2rem; border-radius:2px; width:35%; margin:2rem auto; display:block; color:#fff; outline:none; cursor:pointer; } </style> </head> <body> <h1>DOM PopStateEvent Event Demo</h1> <button onclick="display()" class="btn">Click Me</button> <script> function display(){ window.onpopstate = function(event) { alert("location: " + document.location + ", state: " + JSON.stringify(event.state)); }; history.pushState({ page: 1 }, "title home", "?page=home"); history.pushState({ page: 2 }, "title about", "?page=about"); history.replaceState({ page: 3 }, "title contact", "?page=contact"); history.back(); history.back(); } </script> </body> </html>
Output
This will produce the following output −
Click on “Click Me” button to understand how PopStateEvent Object works −
Click “Ok” −
- Related Articles
- HTML DOM Object Object
- HTML DOM HTML Object
- HTML DOM Ins Object
- HTML DOM HR Object
- HTML DOM Variable Object
- HTML DOM aside Object
- HTML DOM Anchor Object
- HTML DOM TableData Object
- HTML DOM TableHeader Object
- HTML DOM TableRow Object
- HTML DOM Textarea Object
- HTML DOM Meter Object
- HTML DOM MouseEvent Object
- HTML DOM Nav Object
- HTML DOM Ol Object

Advertisements