iframe窗口嵌套,子窗口跳轉重疊在父窗口的問題


window.top //最頂層窗口 
window.self //當前窗口 
window.parent //父級窗口

"window.location.href"、"location.href"是本頁面跳轉

"parent.location.href"是上一層頁面跳轉

"top.location.href"是最外層的頁面跳轉

舉例說明:

如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js這樣寫

"window.location.href"、"location.href":D頁面跳轉

"parent.location.href":C頁面跳轉

"top.location.href":A頁面跳轉

如果D頁面中有form的話,

<form>: form提交后D頁面跳轉

<form target="_blank">: form提交后彈出新頁面

<form target="_parent">: form提交后C頁面跳轉

<form target="_top"> : form提交后A頁面跳轉

關於頁面刷新,D 頁面中這樣寫:

"parent.location.reload();": C頁面刷新 (當然,也可以使用子窗口的 opener 對象來獲得父窗口的對象:window.opener.document.location.reload(); )

"top.location.reload();": A頁面刷新

 

在使用框架時,經常會對框架子頁面進行頁面引導的情況,如果只是簡單的設置location. href="",會使得整個頁面顯示在子框架中,導致出現重疊框架。如何解決呢?很簡單。只要指定子框架的父級框架頁面鏈接至目標頁面即可。如

window.top.framename.location.href = url;

window.parent.location.href=url;

mainframe.location.href=url;

 

原文地址: https://blog.csdn.net/jason_ldh/article/details/33732343


免責聲明!

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



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