"window.location.href"、"location.href"是本頁面跳轉.javascript
"parent.location.href" 是上一層頁面跳轉.html
"top.location.href" 是最外層的頁面跳轉.java
舉例說明:spa
若是A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,若是D中js這樣寫orm
"window.location.href"、"location.href":D頁面跳轉htm
"parent.location.href":C頁面跳轉ip
"top.location.href":A頁面跳轉iframe
若是D頁面中有form的話,it
: form提交後D頁面跳轉io
: form提交後彈出新頁面
: form提交後C頁面跳轉
: form提交後A頁面跳轉
若是訪問的是iframe裏面的頁面,從新加載最外層的頁面
<</span>html>
<</span>head>
<</span>title></</span>title>
<</span>script language="javascript">
function escapeFrame(){
if (window.top.location.href != window.location.href) {
window.top.location.reload();
}
}
</</span>script>
</</span>head>
<</span>body onload="escapeFrame()">
<</span>iframe src="b.html" ></</span>iframe>
</</span>body>
</</span>html>