【H5】ie8如何兼容html5标签(hack)

ie8是识别不了html5语义化标签的,解决方法:

在头部文件的<head></head>里面下如下代码    (这段代码的意思是如果ie版本低于ie8,就创建所有HTML5新标签

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

另外,在公共样式文件中添加html5标签的块定义
article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}


由上俩步即实现ie8中html5标签的识别。
 
原文地址:https://www.cnblogs.com/smilexumu/p/7779666.html