通过JS在IE中使用HTML5元素

通过JS 创建此对于IE未知的HTML5元素,再在CSS定义样式属性:

document.createElement(newElementName)

具体实现:

<html>
<head>
<style>blah { color: red; }</style>

<script>document.createElement("blah")</script>
</head>
<body>
<blah>Hello!</blah>
</body>
</html>

更多详细请参考:《HTML5 Shiv》

批量引入新元素[怿飞]

(function(){
    // from: http://dean.edwards.name/weblog/2007/03/sniff/
    if(!/*@cc_on!@*/0) return;

    var html5= “abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,

figure,footer,hgroup,header,mark,menu,meter,nav,output,progress,section,time,video”.split(‘,’);
    for(var i = 0, len = html5.length; i < len; i++ )
        document.createElement(html5[i]);
    }
})();

很简单,很省事~

可能有关的文章:

Tags : , , ,

Google Reader Yahoo Facebook Twitter Digg FriendFeed Delicious Google Translate
这篇日志发表于2009年06月27日 10:30 上午。 你可以订阅该日志的所有评论通过 RSS 2.0。 你可以发表评论,或者引用通告

发表评论

Anti-Spam Protection by WP-SpamFree

(Ctrl+Enter)

XHTML:你可以使用这些标签:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>