Comment: To enable IE (including IE6) to support HTML5 elements, you need to add a simple document.createElement declaration to the HTML header. For details, please read this article
To make IE (including IE6) support HTML5 elements, we need to add the following JavaScript to the HTML header, which is a simple document.createElement declaration, and use conditional comments to call this js file for IE. Other non-IE browsers such as Opera, FireFox, etc. will ignore this code and there will be no http request.<!–[if IE]>
<script src=></script>
<![endif]->
The above code will only run under IE browser. Another thing to note is that calling the html5.js file in the page must be added to the head element of the page, because the IE browser must know this element before the element is parsed, so this js file cannot be called at the bottom of the page.
This html5 js file is provided by the author on the Google code project for everyone to call directly. Of course, if you think this will affect the speed of your webpage opening, you can download the html5 js file directly and upload it to your server to call it separately.
The following is the code in the js file of html5:
(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( ','),i=e.length;while(i–){document.createElement(e[i])}})()
In addition to calling the js file containing the above code in the web page to enable the IE browser to support HTML5 elements, you can also add the code directly to the web page in the following way.
<!–[if IE]>
<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( ','),i=e.length;while(i–){document.createElement(e[i])}})()
</script>
<![endif]->