0

有没有办法检测移动浏览器中的 HTML 5语义标签支持?

像这样的标签:

<section>, <nav>, <article>, <aside>, <hgroup>, <header>,<footer>

我正在制作具有 2 个版本的移动网站,例如 m.facebook.com 和 touch.facebook.com,我想重定向到支持的手机。在触摸版中,我使用的是 HTML 5 标签。

例如,Android 1.6 不支持 HTML5 并且仍在使用中。所以我想将所有 Android 1.6 设备重定向到 m.mobileversion.com 而不是 touch.mobileversion.com

4

2 回答 2

0

You can use those tags for all browsers/platforms. First, you need to make sure those elements are recognized as block level elements which is all most browsers need since the elements themselves have no special meaning (semantics aside).

section, 
nav, 
article, 
aside, 
hgroup, 
header, 
footer {
display: block;
}

Then, for IE, just include the HTML5 shim in your page which uses a few lines of js to create these elements:

<!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

Don't forget to set your doctype to the HTML5 doctype:

<!DOCTYPE html>
于 2011-05-23T20:54:52.420 回答
0

以下是检测浏览器对 HTML5 元素支持的方法列表。

http://diveintohtml5.info/everything.html

于 2011-12-24T06:39:48.620 回答