HTML5在IE下如何实现?

html-css09

HTML5在IE下如何实现?,第1张

HTML5在IE下实现方法:

一:Coding JavaScript

<!--[if lt IE9]>

<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>

<![endif]-->

二、使用Google的html5shiv包(推荐)

<!--[if lt IE9]>

<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

<![endif]-->

两种方法都需要进行css的初始化:

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

让ie浏览器支持html5标签

HTML5出现也不短了,很多网站的页面都进行了改版,为了降低代码量(不需要起太多的类名),提升加载速度,提高标签的语义性,因此,在网页中大量使用了section,article,header等HTML5标签。自己最近在写响应式布局的范例,里面也使用到了header等标签。还是比较希望能够做成兼容“旧版浏览器”的,在此和大家共享一下,如何让旧浏览器支持HTML5新增标签。

HTML5 新标签兼容旧版本浏览器的方法