我正在尝试如何使用window.onpopstate
。我认为它必须包含浏览器back
和forward
按钮,但它也可以处理任何链接......那为什么会发生呢?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
window.onpopstate = function( e ) {
console.log("!!!!!!!!!!!!!!");
}
</script>
</head>
<body>
<a href="#1">first</a> <a href="#2">second</a>
</body>
</html>