【发布时间】:2016-02-04 00:35:25
【问题描述】:
我正在查看这个 javascript 代码的 sn-p
if (history) {
var action = settings.replaceState ? history.replaceState : history.pushState;
if (action) {
// next line throws the error
action(null, null, window.location.pathname + window.location.search + '#' + hash);
}
}
settings.replaceState == true
微软最新的东西给了我这个
调用对象无效
在 Chrome 中,同样的代码会抛出这个
未捕获的类型错误:非法调用
我在 Firefox 中收到此错误
TypeError:在未实现接口 History 的对象上调用了“replaceState”。
当我调试时,历史看起来应该是这样,并且其中有一个包含此方法的原型。
除了不同的错误信息,谁能告诉我这里发生了什么?
【问题讨论】:
标签: javascript browser-history