Regarding using History.js to manage browser state RRS feed

  • Question

  • User264732274 posted
    History.pushState({state:1}, "State 1", "?state=1")

    suppose if i need to store page number and sort order then what code i need to write?

    url part is mandatory ?

    how to get back the state when user click on browser back or forward buttons?

    suppose i have a object like this

    var PageState= {

    so can i store it like this way 

    History.pushState({state:PageState}, null, null); ?

    when user click on browser back and forward button then how could i get back the state from browser history using History.js lib ?

    looking for code sample. thanks

    Thursday, December 31, 2015 2:38 PM


  • User61956409 posted

    Hi sudip_inn,

    From this link we could find this

    Pushes a new state to the browser;  data  can be null or an object,  title  can be null or a string,  url  must be a string

    pushState method accepts three parameters, and data could be an object, so your javascript object “PageState” should be stored as the value of data argument.


    History.pushState({state:PageState}, null, null); ?

     url  must be a string, so we should not specify a null value to url.

     Besides, you could post your question on Stackoverflow and be sure to use the history.js  tag when asking your question.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 1, 2016 7:14 AM