强制浏览器忽略HTML 5功能 [英] Force browser to ignore HTML 5 features

查看:110
本文介绍了强制浏览器忽略HTML 5功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个遗留网站,在FF 3.6,IE 7到8等正确呈现,但在FF 9失败。
$ b 问题是,一个旧的5)网站使用的第三方JS框架(Woodstock)为一些HTML元素添加了一个 HIDDEN 属性,所以当我查看萤火虫中的HTML时,我看到下面的代码:

 < table id =foohidden => 

这些页面正在提供:

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Transitional // EN
http://www.w3.org/TR/xhtml1/ DTD / XHTML1-transitional.dtd>

在HTML 4浏览器上没有 HIDDEN 属性。但是支持HTML 5的最新浏览器会解释这个属性,并隐藏需要显示的元素。

修改(不支持的)第三方框架以避免使用 HIDDEN 属性。

是否可以强制浏览器像HTML 4那样呈现页面,而不是对HTML 5功能做任何解释?其他建议欢迎...

解决方案

除IE以外的浏览器只实现一个HTML(好,除了怪癖模式)。

然而,所有的 hidden 属性都会触发UA样式表中的一些样式规则。您可以添加自己的样式规则来覆盖这些规则。这些规则的复杂程度取决于框架将元素添加到哪些元素,但是一种综合的方法是从HTML5规范或从<规范< a href =http://mxr.mozilla.org/mozilla-central/source/layout/style/html.css =noreferrer> http://mxr.mozilla.org/mozilla-central/source/ layout / style / html.css ,除了涉及 hidden 的内容外,只要将它们放在页面链接的样式表中即可。

b $ b

I have a legacy website which renders correctly in FF 3.6, IE 7 to 8 etc but fails in FF 9.

The issue is that an old (pre HTML 5) third party JS framework (Woodstock) used by the site adds a HIDDEN attribute to some HTML elements, so when I look at the HTML in firebug I see code like:

<table id="foo" hidden="">

These pages are being served with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This worked fine on browsers designed for HTML 4 which did not have a HIDDEN attribute. But the latest browsers that support HTML 5 interpret this attribute and hide elements that I need to be visible.

It will be very difficult to modify the (unsupported) third party framework to avoid the use of the HIDDEN attribute.

Is it possible to force browsers to render pages as though they are HTML 4, and not make any interpretation of HTML 5 features? Other suggestions welcome...

解决方案

Browsers other than IE just implement one HTML (well, with the exception of quirks mode).

However all the hidden attribute does is trigger some style rules in the UA stylesheet. You can add your own style rules to just override those. How complicated those rules need to be depends on what elements the framework adds the elements to, but one comprehensive approach would be to copy the various display rules from the HTML5 spec or from http://mxr.mozilla.org/mozilla-central/source/layout/style/html.css with the exception of the ones involving hidden and just put them in a stylesheet that your page links to.

这篇关于强制浏览器忽略HTML 5功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆