继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

form的target属性作用域的问题

慕哥9229398
关注TA
已关注
手记 1099
粉丝 198
获赞 911

当设置form的target属性为iframe的name时,浏览器查找iframe的范围并不只是form所在body中的iframe,而是_top页面及子孙页面中全部iframe。
测试如下:

webp

图片.png


a2为iframe a1中的iframe页面,在a2页面中提交form,form的target设置为b2,b2为iframe b1中的iframe,点击提交按钮,可以看到b2跳转成功,如下图:

webp

图片.png


index.html


<html>
  <body>
    index page    <iframe name="a1" src="a1.html" width="100%" height="200"></iframe>
    <iframe name="b1" src="b1.html" width="100%" height="200"></iframe>
  </body></html>

a1.html

<html>  <body>
    a1 page    <iframe name="a2" src="a2.html" width="100%" height="100" />
  </body></html>

b1.html

<html>  <body>
    a2 page, form target is b2, action is http://www.baidu.com.    <form target="b2" action="http://www.baidu.com">
      <input type="submit"/>
    </form>
  </body></html>

a2.html

<html>  <body>
    b1 page, below frame is b2.    <iframe name="b2" width="100%" height="100" />
  </body></html>



作者:sakura_na
链接:https://www.jianshu.com/p/b7ad335ac7df


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP