js中top.location.href、parent.location.href用法
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>; |
|
也可以直接在表单提交是的target加个即可
<form>: form提交后D页面跳转
<form target=_blank>: form提交后弹出新页面
<form target=_parent>: form提交后C页面跳转






