`

ie浏览器兼容html5新标签

 
阅读更多
html5提供了强大的新标签及新属性,却只有高级浏览器兼容,那么为了ie低版本浏览器的兼容该怎么办呢?

为了确保所有新的HTML5元素能以block元素正确渲染,我们会在css中定义:

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

但是低版本浏览器不识别这些标签,那么解决方法如下:

(一)支持IE兼容HTML5标签的方法
document.createElement('TagName');
<head>
<script>
function createTags() {
       var tags = ['header', 'aside', 'footer', 'nav', 'section', 'article', 'hgroup', 'time'];
        for (var i = 0; i < tags.length; i++) {
          document.createElement(tags[i]);
        }
   }
</script></head>


(二)Google Code Project现成的js

1、http://html5shiv.googlecode.com/svn/trunk/html5.js shiv的在线脚本地址
2、http://html5shim.googlecode.com/svn/trunk/html5.js shim的脚本脚本地址
<head>
<!--[if lt IE 9]>  
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">  
<![endif]-->  
</head>


参考:http://www.camnpr.com/archives/617.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics