window.location.href的用法


javascript中的location.href有很多種用法,主要如下。

self.location.href="/url" 當前頁面打開URL頁面
location.href="/url" 當前頁面打開URL頁面
windows.location.href="/url" 當前頁面打開URL頁面,前面三個用法相同。
this.location.href="/url" 當前頁面打開URL頁面
parent.location.href="/url" 在父頁面打開新頁面
top.location.href="/url" 在頂層頁面打開新頁面

如果頁面中自定義了frame,那么可將parent self top換為自定義frame的名稱,效果是在frame窗口打開url地址

此外,window.location.href=window.location.href;和window.location.Reload()和都是刷新當前頁面。區別在於是否有提交數據。當有提交數據時,window.location.Reload()會提示是否提交,window.location.href=window.location.href;則是向指定的url提交數據


免責聲明!

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



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