【发布时间】:2011-04-22 20:11:21
【问题描述】:
Chrome 和 Safari 不会触发 HTML5 onpopstate 事件。
这是我的例子:
<!doctype html>
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
window.onpopstate = function(e) {
document.getElementById("log").innerHTML = "HELLO";
}
$(function() {
$("a").click(function(e) {
e.preventDefault();
window.history.pushState({page: $(this).index()}, $(this).html(), $(this).attr('href'));
});
});
</script>
</head>
<body>
<a href="new-state">Foo</a>
<a href="other-state">Hallo</a>
<div id="log"></div>
</body>
</html>
【问题讨论】:
标签: jquery html google-chrome safari jquery-events