HTML5历史推送状态不工作

HTML5 history pushState is not working

本文关键字:工作 状态 历史 HTML5      更新时间:2023-09-26

不知道我做错了什么,但这一小段代码不起作用:

window.history.pushState("foo", "foo", "foo");

将在firefox 29中生成以下错误:

TypeError: window.history.pushState is not a function

显然我包含的一个脚本有一个声明:

var history = ...;

我不知道的是,根目录下的所有变量实际上都在窗口范围内,所以自定义历史变量实际上覆盖了原来的window.history.

Please try as

假设http://mozilla.org/foo.html执行以下JavaScript:

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

它应该按照mozila的要求工作。

请查看更多关于Mozilla Link