ie8支持html5吗

2023-01-07,

ie8不支持html5,若是想要ie8支持html5,有两种方式:1、引用google的html5.js文件,并将代码放到head标签区间;2、通过添加“while (i--){document.createElement(e[i])}”代码实现支持HTML5元素。

本教程操作环境:Windows10系统、HTML5版、Dell G3电脑。

ie8支持html5吗?

不支持。

但是让IE(ie6/ie7/ie8)支持HTML5元素,我们可以在HTML头部添加以下JavaScript,这是一个简单的document.createElement声明,利用条件注释针对IE来调用这个js文件。Opera,FireFox等其他非IE浏览器就会忽视这段代码,也不会存在http请求。

  方式一:引用google的html5.js文件,代码内容可以自己下载下来看。

<!–[if lt IE9]> 
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]–>

  将以上代码放到head标签区间

  方式二:自己coding JS搞定。

<script> 
   (function() {
     if (! 
     /*@cc_on!@*/
     0) return;
     var e = "abbr, article, aside, audio, canvas, datalist, details, dialog, eventsource, figure, footer, header, hgroup, mark, menu, meter, nav, output, progress, section, time, video".split(', ');
     var i= e.length;
     while (i--){
         document.createElement(e[i])
     } 
})() 
</script>

  不管你用上面哪中方式,请记得在CSS中进行如下定义,目的是让这些标签成为块状元素,just like div。

/*html5*/
article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}

推荐学习:《HTML5视频教程》

以上就是ie8支持html5吗的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《ie8支持html5吗.doc》

下载本文的Word格式文档,以方便收藏与打印。