js修改window對象中的url歷史記錄


//頁面地址:http://localhost/11/account.html
//訪問頁面后,地址變為:http://localhost/11/account.html?type=banana
console.log(window.location.search); // 空
window.history.pushState('','', window.location.href + '&type=banana');
console.log(window.location.search); //&type=banana
 
        

點擊瀏覽器返回按鈕,返回的頁面地址是:http://localhost/11/account.html

通過這種方式,修改url參數,頁面不會被重新加載,可用於分頁加載。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM