开发者

what is the state object passed to history.pushState and what does it do?

What is the stateObj passed to histor开发者_如何学Pythony.pushState and what does it do?

For example, history.pushState(stateObj, title, url);


The state object, as defined by the spec, is any object that you, the author, want to associate with that state:

Pages can add state objects between their entry in the session history and the next ("forward") entry. These are then returned to the script when the user (or script) goes back in the history

The MDN has a more-practical (Firefox-specific) definition:

The state object can be anything that you can pass to JSON.stringify. 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 JSON representation of a state object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜