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