javascript中的location.href有很多種用法,主要如下。
self.location.href=”/url” 當(dāng)前頁面打開URL頁面
location.href=”/url” 當(dāng)前頁面打開URL頁面
windows.location.href=”/url” 當(dāng)前頁面打開URL頁面,前面三個用法相同。
this.location.href=”/url” 當(dāng)前頁面打開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()和都是刷新當(dāng)前頁面。區(qū)別在于是否有提交數(shù)據(jù)。當(dāng)有提交數(shù)據(jù)時,window.location.Reload()會提示是否提交,window.location.href=window.location.href;則是向指定的url提交數(shù)據(jù)
新聞熱點
疑難解答
圖片精選