Firefox 下 innerHTML 的一个 BUG

作者:blank 来源:怿飞blog 时间:2008-08-05 18:19:00 

今天同事 明城 在项目中碰到一个 BUG,代码具体如下:

当你在 Firefox2.0+ 或 Firefox3.0+ 中点击链接后,会发现 innerHTML 插入的内容为<a>21</a>,而其他浏览器测试(IE6、IE7、Safari3.0+、Opera9.0+)都正常,插入内容均为文字 21。

估计是 Firefox 的一个 BUG,查找了官方网站的 BUG库,果真找到别人提交的该类问题——《Setting innerHTML on a block element inside an inline element creates extra copies of the inline element》(Bug 381808)。

我们可以参阅下8楼的 Boris Zbarsky 给出的个人解释:

There are two separate concepts of block vs inline. One in CSS and one in
HTML. They don’t match.

In any case, the point is that in HTML <b> is not allowed to contain <div> (so
the <b> needs to get closed), but the text needs to be bold for compat so we do
residual style handling. HTML5 is going to define a different method of doing
this anyway, so at that point we’ll need to revisit this bug.

虽然这是一个 BUG,但 BUG 的造成也却是人为的不良习惯造成的,在 WEB 标准中严格来说内联元素是不允许包含块级元素的(扩展阅读:《Allowed nesting of elements in HTML 4 Strict (and XHTML 1.0 Strict)》)。

标签:BUG,firefox,innerhtml
0
投稿

猜你喜欢

  • 交互设计实用指南系列(3)—“有效性”之“适时帮助”

    2009-12-25 14:29:00
  • 请正确认识MySQL对服务器端光标的限制

    2008-12-17 14:58:00
  • ASP 操作cookies的方法

    2011-03-10 11:24:00
  • 这种sql写法真的会导致索引失效吗

    2024-01-18 18:31:47
  • 安装SQL Server 2005时出现计数器错误

    2008-11-28 14:19:00
  • python 内置函数-range()+zip()+sorted()+map()+reduce()+filter()

    2022-09-23 19:48:01
  • python实现定时提取实时日志程序

    2023-03-03 22:31:24
  • Python如何批量获取文件夹的大小并保存

    2023-10-10 19:49:37
  • 解决Python requests库编码 socks5代理的问题

    2023-01-29 13:27:28
  • 分析详解python多线程与多进程区别

    2022-01-19 01:13:54
  • Python多线程获取返回值代码实例

    2023-03-25 17:42:27
  • ASP连接SQL2005数据库连接代码

    2011-03-25 10:44:00
  • SQL中创建存储过程

    2024-01-23 17:42:58
  • PHP高级编程实例:编写守护进程

    2023-10-27 02:03:22
  • 菜鸟课堂:玩转MySQL数据库 性能优化八法

    2009-03-25 14:44:00
  • Echarts.js无法引入问题解决方案

    2023-08-12 22:57:26
  • 关于python3的ThreadPoolExecutor线程池大小设置

    2023-12-05 13:37:57
  • 解决无法配置SQL2005问题

    2024-01-22 15:56:51
  • CentOS6.9下mysql 5.7.17安装配置方法图文教程

    2024-01-23 12:26:03
  • 给Python初学者的一些编程技巧

    2023-05-27 21:41:30
  • asp之家 网络编程 m.aspxhome.com