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

  • Home
  • SEARCH
  • 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 8657609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:33:50+00:00 2026-06-12T15:33:50+00:00

Would someone please explain states to me? For instance, with the history.js plugin. History.pushState({state:1},

  • 0

Would someone please explain states to me?

For instance, with the history.js plugin.

History.pushState({state:1}, "State 1", "?state=1"); // logs {state:1}, "State 1", "?state=1"

I understand the last parameter, as it’s the URL that’s pushed to the address bar, but I have no idea of the first two. Understanding these would help me implement history.js into my site, as I’m having trouble with back/forward navigation.

On the Mozilla dev site it says:

state object — The state object is a JavaScript object which is associated with the new history entry created by pushState(). Whenever the user navigates to the new state, a popstate event is fired, and the state property of the event contains a copy of the history entry’s state object.
The state object can be anything that can be serialized. Because Firefox saves state objects to the user’s disk so they can be restored after the user restarts her browser, we impose a size limit of 640k characters on the serialized representation of a state object. If you pass a state object whose serialized representation is larger than this to pushState(), the method will throw an exception. If you need more space than this, you’re encouraged to use sessionStorage and/or localStorage.

Is state just a copy of the code that was loaded using AJAX? Or is it just a representation of that code, so it can be called upon?

Any insight to this is appreciated!

  • 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-06-12T15:33:52+00:00Added an answer on June 12, 2026 at 3:33 pm

    The state object is any Javascript object – it can be a single variable, or a huge hashmap of functions and values. It’s whatever data you want to use to represent the ‘state’ of your app at that point in time. Something like this is quite common:

    var viewModel = {
        title: 'FAQs',
        url: 'faqs.html',
        favouriteColor: 'green',
        stepsCompleted: 4
    };
    
    history.pushState(viewModel, viewModel.title, viewModel.url);
    

    That’s basically creating an object with anything needed to ‘remember’ and restore the state later – for instance if the user is following a wizard-style step-by-step form or suchlike.

    The second parameter, title, is largely ignored by browsers for the time being, but is probably intended for use-cases like forwards/backwards navigation, where the page title might need to be updated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please explain when would I want to use delegation instead of inheritance?
Can someone please explain me why would a UDP Server not need to use
I would like to access a MySQL database using PHP. Can someone please explain
Would someone please be able to explain to me how to properly install JavaMail
private final String[] okFileExtensions = new String[] { csv }; Would someone please explain
Can someone please explain the difference between the following cases and where would we
Can someone please explain to me how you would create a star schema starting
Would someone please explain the difference? Are these the same product, and if not
I googled and got only a few articles about MEF. Would someone please explain
Would be someone please to explain the next: In the Programming Perl book postfix

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.