javascript – 传递给history.pushState的状态对象是什么?

前端之家收集整理的这篇文章主要介绍了javascript – 传递给history.pushState的状态对象是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
stateObj是传递给history.pushState的,它是做什么的?

例如,history.pushState(stateObj,title,url);

解决方法

状态对象,as defined by the spec,是您,作者想要与该状态相关联的任何对象:

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

MDN具有更实用(特定于Firefox的)定义:

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.

原文链接:https://www.f2er.com/js/153833.html

猜你在找的JavaScript相关文章