jquery - Javascript history.pushState - Stack Overflow

I found example of history.pushState() through stackoverflow but I don't understand what each thin

I found example of history.pushState() through stackoverflow but I don't understand what each thing does. this is what I have

var stateObj = {
    foo: "bar"
};
history.pushStates(stateObj, "page 2", "page2.html");

so can anyone explain what stateObj holds and what "page 2" is in this script? Why does the object have foo: "bar"?

Thanks in advance.

I found example of history.pushState() through stackoverflow but I don't understand what each thing does. this is what I have

var stateObj = {
    foo: "bar"
};
history.pushStates(stateObj, "page 2", "page2.html");

so can anyone explain what stateObj holds and what "page 2" is in this script? Why does the object have foo: "bar"?

Thanks in advance.

Share Improve this question edited Apr 4, 2012 at 20:11 nickytonline 6,9817 gold badges47 silver badges76 bronze badges asked Apr 4, 2012 at 20:08 GrigorGrigor 4,05910 gold badges43 silver badges80 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

this link might be of use:

https://developer.mozilla/en/DOM/Manipulating_the_browser_history#The_pushState%28%29.C2.A0method

the first parameter, stateObj in the example, is an arbitrary context object containing whatever you'd like. It's accessed when the user visits a different page and then navigates back to your page using their browser's Back button. see the popState event for more information there.

the second paramater is currently unused; it's remended to pass the empty string here.

the last parameter is the URL associated with the context object. It does not change the location of the current page.

https://developer.mozilla/en/DOM/Manipulating_the_browser_history#The_pushState().C2.A0method

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744978945a4604320.html

相关推荐

  • jquery - Javascript history.pushState - Stack Overflow

    I found example of history.pushState() through stackoverflow but I don't understand what each thin

    22小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信