0

我正在尝试这段代码:

<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");
  });
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
</body>
</html>

我希望当我单击 a 时p,URL 的路径将更改为bar.html. 我正在从我的桌面尝试这个文件,所以 URL 看起来像file:///C:/Documents%20and%20Settings/Cupidvogel/Desktop/hist.html. 但是,当我单击 a 时没有任何反应p。我在这里做错了什么?

4

0 回答 0