Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6200919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:27:25+00:00 2026-05-24T04:27:25+00:00

I am trying to understand HTML5 history object. Here is a simple example which

  • 0

I am trying to understand HTML5 history object. Here is a simple example which I started off with.

    function addDialog(){
         document.getElementById('d').style.display ='';
         history.pushState({name:"changed"},"","#newURL");
    }

    window.onpopstate = function(e){  
        alert(e.state);
    }

I have a div with an id d for which display property is none. On clicking a link, I will display the div and change the history so that new url will be loaded.

When I copy paste the new url, popstate event is fired and I get null for e.state.

From what I understand, if I load the new url http://example.com#newURL, e.state should point to the object which I pushed using pushstate.

Please correct me if I am wrong and also I would like to know when e.state gets populated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:27:26+00:00Added an answer on May 24, 2026 at 4:27 am

    As I tested, the e.state only get the pop state that you add to the history when you click in the Back or Forward button. Otherwise, it will give you the null.

    You can use parameters to your URL so you can test if the request came from a history call or from an URL in the location bar.

    onpopstate = function(event) {
        alert('popEvent: ' + event);
        if(event.state){
            setupPage(event.state);
        } else {
            setupPage(getQStringParam('zid'));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to do a simple drag and drop example in HTML5 - but when
I'am trying to understand the example from program_options of the boost library ( http://www.boost.org/doc/libs/1_38_0/doc/html/program_options/tutorial.html#id3761458
I'm trying to understand if I can debug a stand alone .js file which
I'm trying to understand the definition of NPO. I read the definition here :
I'm trying to understand the tspan tag in svg and here is something weird.
I'm trying to understand the simplest background transition possible using only HTML5 and CSS3
I'm trying out the HTML5 localStorage method for saving data. As I understand it,
I've been evaluating HTML5 audio on iOS 4 and have been trying to understand
I have this javascript function I am trying to understand. I don't know if
I'm trying to understand this bit of code: in display.php: <html> ... <body> <table>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.