How to use HTML5 in IE 7?

前端 未结 8 1330
长发绾君心
长发绾君心 2021-02-08 11:24

I was wondering whether there is a way to make html5 code visible in Internet Explorer 7 or less.

For example

8条回答
  •  情深已故
    2021-02-08 12:15

    IE < 9 doesn't recognize the HTML5 elements and will not generate them. So I use this bit of JS to do the generation:

    var e = ("abbr,article,aside,audio,canvas,datalist,details,
    figure,footer,header,hgroup,mark,menu,meter,nav,output,
    progress,section,time,video,figcaption,summary").split(',');
    
    for (var i = 0; i < e.length; i++){
        document.createElement(e[i]);
    }
    

    I use this conditional comment to check whether I need to run the script

    
    

    Of course, you will need to style the tags for IE < 9, but you would need to anyway.

提交回复
热议问题