我想弄清楚如何使pushState工作,所以我用一個簡單的HTML頁面進行測試,其中包含一個按鈕,如下所示,但它不會更改網址或似乎做任何事情。HTML history.pushState不能正常工作
<html>
<body>
<div id="test">
<button id="btn">Click Me</button>
</div>
<script>
document.getElementById("btn").onclick=function(){
history.pushState({}, '', 'newurl.html');
}
</script>
</body>
</html>
適合我... – Oriol