解决IE8不兼容HTML5标签的方法

来源:互联网 发布:c语言判断数字的位数 编辑:程序博客网 时间:2024/05/23 00:12

ie8是不支持H5的,所以很多新加的标签都无效,如:nav/aside/section等,不过技术嘛,既然有问题,那么就会有对应的解决方案。

方法一 :使用Google的html5shiv包

<head><!--[if lt IE9]>     <script src="http://cdn.bootcss.com/html5shiv/r29/html5.min.js"></script><![endif]--><!-- ... --></head>
/*记得css初始化一下标签*/article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}

方法二 :添加js代码

<!--[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]-->

参考来源:http://www.cnblogs.com/Capricornus/archive/2013/03/26/2982122.html

0 0