"window.location.href"、"location.href"是本頁(yè)面跳轉(zhuǎn).
"parent.location.href" 是上一層頁(yè)面跳轉(zhuǎn).
"top.location.href" 是最外層的頁(yè)面跳轉(zhuǎn).
舉例說(shuō)明:
如果A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js這樣寫(xiě)
"window.location.href"、"location.href":D頁(yè)面跳轉(zhuǎn)
"parent.location.href":C頁(yè)面跳轉(zhuǎn)
"top.location.href":A頁(yè)面跳轉(zhuǎn)
如果D頁(yè)面中有form的話(huà),
<form>: form提交后D頁(yè)面跳轉(zhuǎn)
<form target="_blank">: form提交后彈出新頁(yè)面
<form target="_parent">: form提交后C頁(yè)面跳轉(zhuǎn)
<form target="_top"> : form提交后A頁(yè)面跳轉(zhuǎn)
如果訪(fǎng)問(wèn)的是iframe里面的頁(yè)面,重新加載最外層的頁(yè)面
<html>
<head>
<title></title>
<script language="javascript">
function escapeFrame(){
if (window.top.location.href != window.location.href) {
window.top.location.reload();
}
}
</script>
</head>
<body onload="escapeFrame()">
<iframe src="b.html" ></iframe>
</body>
</html>
posted on 2011-06-28 10:25
secret_x15 閱讀(5495)
評(píng)論(1) 編輯 收藏 所屬分類(lèi):
js