window.location.href和window.location.replace的區別


在頁面中逐級進行點擊請求以下頁面:a.html->b.html->c.html

window.location.href 做跳轉 window.history.go(-1);window.history.back(); 方法時,會向服務器進行請求,根據服務器記錄的請求進行跳轉,因此會正確返回對應的頁面a.html

window.location.replace 做跳轉 window.history.go(-1);window.history.back(); 方法時,不會向服務器進行請求,因此只會跳轉至a.html,未能返回到上級b.html


免責聲明!

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



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