使用js iframe框架頁(yè)面跳轉(zhuǎn)(跳出父框架)
2022-12-06 加入收藏
常用的iframe操作語(yǔ)句
"window.location.href"、"location.href"是本頁(yè)面跳轉(zhuǎn)
"parent.location.href"是上一層頁(yè)面跳轉(zhuǎn)
"top.location.href"是最外層的頁(yè)面跳轉(zhuǎn)
通過(guò)javascript從 框架頁(yè) 向 父框架
parent.location.href="index.asp";
or
top.location.href="index.asp";
例
1.跳出框架,在父頁(yè)面。
jsp:
代碼如下 | 復(fù)制代碼 |
<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.從一個(gè)框架跳轉(zhuǎn)到 name="main" 的框架里。
代碼如下 | 復(fù)制代碼 |
<script language="javascript"> var key = document.getElementById(" ## ").value; window.parent.main .location.href= "welcome.en ? key=" + key; </script> |
3.ContentList 當(dāng)前頁(yè)的iframe名字
代碼如下 | 復(fù)制代碼 |
window.ContentList.location.href = '../welcome.en'; |