window.location.href、location.href是本页面跳转
parent.location.href是上一层页面跳转
top.location.href是最外层的页面跳转
举例说明:
window.location.href、location.href:
例:
window.location.href= 'wapsend1.asp?zimu=A&rev= ' + form1.rev.value ;
parent.location.href:C页面跳转
例:
window.parent.parent.location.href=“你定义要跳转的页面”
top.location.href:A页面跳转
例:
在form提交表单的时候有个属性可能对上面的(2)的情况有用target=_top
<form name=loginForm action=Login.action method=post target=_top>
</form>
例2:
echo <iframe width=0 height=0 frameborder=0 scrolling=auto src='登录论坛' onload='reurl()'></iframe>;
echo <script> function reurl(){top.location.href='.$url.'}</script>;
也可以直接在表单提交是的target加个即可
: form提交后D页面跳转
: form提交后弹出新页面
: form提交后C页面跳转
window.top.location.href 和 window.location.href 的区别
if (window.location.href == window.top.location.href) { window.top.location.href = “/index.html”; }
top.window.location.reload 中top是什么意思 父框架的对象
比如
有网页 1.htm <span id='str'>显示内容1</span> <iframe src='2.htm'></iframe>
2.htm <input type='button' value='改变显示内容'onclick="top.document.getElementById('str').innerHTML='显示内容2222222';" />
也就是 如果 2.htm 里面 使用了: top.window.location.reload 那么就是 刷新父页面 1.htm 如果2.htm里面使用的是: window.location.reload 那就是 刷新框架 2.htm 父页面1.htm 不改变