踩 IE

I hate IE forever.

测试3种浏览器对打印表格的支持程度

, ,

先看这个测试页
http://my.opera.com/tifa/homes/files/table_print.html
这是一个有thead、tfoot、tbody元素和打印分页样式的表格。。
英文稍好的可以看W3C的这段文档:
http://www.w3.org/TR/REC-html40/struct/tables.html#edef-THEAD
摘要:
Table rows may be grouped into a table head, table foot, and one or more table body sections, using the THEAD, TFOOT and TBODY elements, respectively. This division enables user agents to support scrolling of table bodies independently of the table head and foot. When long tables are printed, the table head and foot information may be repeated on each page that contains table data.

简单来说,根据W3C HTML 4.0的规范,thead和tfoot是表头和表脚,它们始终出现在表格内容的头尾部。当一个很长的表格需要分页打印时,表头和表脚应该始终出现在每一页表格的头尾部。

现在我测试一下3种浏览器(Microsoft Internet Explorer、Opera、Mozilla Firefox)对这个规范的遵守程度:

在通常模式下浏览,三种浏览器几乎没有分别,它们都遵守了thead和tfoot始终在表格头尾的规范。但当我试图打印这个表格时问题出现了。

  1. 当一个表格很长,必须要分页显示时,Opera的表尾显示非常奇怪,显然这是一个BUG。opera wrong tfoot
  2. 不论你是否加上强制分页的样式(page-break-after:always;),IE和Opera都没有遵守表头和表脚出现在所有分页表格头尾部的规定。而是直接把表格从中截断,头尾分别在第一页和最后一页。
  3. Firefox必须在要分页的位置加上分页的样式头尾才会出现在下一页,否则除了第一页和最后一页,其他页面都只能显示表头,如果仔细观察尾部,会发现表尾其实是被“隐藏”了,只能看到字的一小部分。BUG?firefox hide tfoot
  4. Opera居然不支持打印时的分页属性(page-break-after:always;),这让我大跌眼镜。要知道,这个东西就连古老的IE5都支持。
  5. 当用CSS设定边框合并的时候(border-collapse:collapse;)除第一页外所有分页表格的最上方都缺少了一个边框,显然这个边框被截断到了上一页,这个问题三个浏览器同时存在。虽然符合标准,但我认为这是浏览器不够智能,测试时也不够细心所致。all hide top border
  6. Opera不支持打印时的颜色定义,原本红色的字变成了黑色,见前面的截图。

结论就是,三种浏览器都不尽如人意,Firefox相对表现最好,基本实现了W3C标准,IE除了没有实现thead和tfoot外表现也算正常,Opera的表现最差。

如何使.net开发的程序正确支持firefox等非ie浏览器关于前两次BUG在Opera官方论坛上的讨论

Comments

云梯49 Saturday, November 5, 2005 1:55:49 AM

版主果然厉害,连这些东西都考虑到了!

虽然很少用浏览器的打印功能,但对版主这样认真负责的行为还是一个字:

赞!

perkypan Saturday, November 12, 2005 1:28:28 PM

122 TIFA姐姐的研究~

Anonymous Monday, May 22, 2006 2:01:47 AM

xmlhtml.com.cn writes: 够细致

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies