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 badges2 Answers
Reset to default 6this 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
评论列表(0条)