History.js不能在Internet Explorer中工作
问题描述:
我想让history.js在Internet Explorer中工作,因为我需要history.pushState()才能工作。我已经阅读了GitHub上的说明(https://github.com/browserstate/History.js/),并试图实现它,但没有取得任何成功。 这里就是我有History.js不能在Internet Explorer中工作
<!DOCTYPE html>
<html>
<head>
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!-- History.js -->
<script defer src="http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>
<script type="text/javascript">
function addHistory(){
// Prepare
var History = window.History; // Note: We are using a capital H instead of a lower h
// Change our States
History.pushState(null, null, "mylink.html");
}
</script>
</head>
<body>
<a href="mylink.html">My Link</a>
<a href="otherlink.html">Other Link</a>
<button onclick="addHistory()" type="button">Add History</button>
</body>
不知道我在做什么错,但它绝对不是IE8或IE9工作。它可以在Firefox中工作,但这可能是因为Firefox实际上支持history.pushstate。任何帮助表示赞赏
答
在第二个<script>
标记删除词defer
。
因为,如果你提到这个词,这意味着推迟。 (如果您想从中减少页面渲染阻塞,请不要将其删除)。这也是IE非常严格,这就是为什么你有这个问题。希望它可以帮助
参考this
是它的工作其他地方,或者你只尝试IE? – Tyrsius 2012-07-05 21:14:13
每个版本的IE或你尝试过什么版本? – 2012-07-05 21:22:58
我已经试过IE8和IE9,对不起,离开了。它适用于Firefox,但这可能是因为它默认支持history.pushstate? – Wilcoholic 2012-07-05 21:31:55