如何在 IE 中使用 HTML5 元素

让样式在 IE 中作用到未知的元素上——仅需 JS 创建此未知元素即可。

Hello World!

 

 1 < html >
 2 < head >
 3 ExpandedBlockStart.gifContractedBlock.gif < style >
 4ExpandedSubBlockStart.gifContractedSubBlock.gifsection {}{ color: red; }
</ style >
 5 ExpandedBlockStart.gifContractedBlock.gif < script >
 6document.createElement("section")
</ script >
 7 </ head >
 8 < body >
 9 < section > Hello World! </ section >
10 </ body >
11 </ html >

方便地使用HTML5元素

ContractedBlock.gif ExpandedBlockStart.gif JS for HTML5
1 (function(){    
2 // from:http://dean.edwards.name/weblog/2007/03/sniff/    if(!/*@cc_on!@*/0) return;     
3  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(',');    
4   for(var i = 0, len = html5.length; i < len; i++ )    {        
5      document.createElement(html5[i]);    
6   }
7 })();

 

Code 下载

HelloWorld.rar

参考资料

John Resig  《HTML5 Shiv》

转载于:https://www.cnblogs.com/dinguaa/archive/2009/07/14/1523722.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值