form的target属性作用域的问题

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

图片.png

a2为iframe a1中的iframe页面,在a2页面中提交form,form的target设置为b2,b2为iframe b1中的iframe,点击提交按钮,可以看到b2跳转成功,如下图:
图片.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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 28,078评论 1 45
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,477评论 19 139
  • HTML 5 HTML5概述 因特网上的信息是以网页的形式展示给用户的,因此网页是网络信息传递的载体。网页文件是用...
    阿啊阿吖丁阅读 9,721评论 0 0
  • 无所事事的一天,整理床铺、洗晒,让每天安睡的地方整洁温馨,让肌肤可以安心地贴近,谁说又是无所事事呢! 生活就是每一...
    梧桐文竹阅读 780评论 0 0
  • 首先看到ServiceManager可能会想到C++世界的ServiceManager,但是我要说明的这是Java...
    NoOneDev阅读 10,355评论 2 4