使用js iframe框架頁面跳轉(zhuǎn)(跳出父框架)
2022-12-06 加入收藏
常用的iframe操作語句
"window.location.href"、"location.href"是本頁面跳轉(zhuǎn)
"parent.location.href"是上一層頁面跳轉(zhuǎn)
"top.location.href"是最外層的頁面跳轉(zhuǎn)
通過javascript從 框架頁 向 父框架
parent.location.href="index.asp";
or
top.location.href="index.asp";
例
1.跳出框架,在父頁面。
jsp:
| 代碼如下 | 復制代碼 |
| <script language="javascript"> window.parent.frames.location.href="../welcome.en" </script> | |
java:
PrintWriter out = response.getWriter();
out.write("<script type='text/javascript'>window.parent.frames.location.href = '../welcome.en';</script>");
return;
2.從一個框架跳轉(zhuǎn)到 name="main" 的框架里。
| 代碼如下 | 復制代碼 |
| <script language="javascript"> var key = document.getElementById(" ## ").value; window.parent.main .location.href= "welcome.en ? key=" + key; </script> | |
3.ContentList 當前頁的iframe名字
| 代碼如下 | 復制代碼 |
| window.ContentList.location.href = '../welcome.en'; | |