"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>