Posted By

rtcrm on 04/24/09


ie html browser compatibility html5

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


HTML5 enabling script

 / Published in: JavaScript


Since HTML5 is getting more attention by way of marking up our new pages, and the only way to get IE to acknowledge the new elements, such as <article>, is to use the HTML5 shiv, here’s a mini script that enables all the new elements.

Usage & Download

The html5.js and must be inserted in the head element (this is because IE needs to know about the element before it comes to render them — so it can’t sit in the footer of the page, i.e. below the elements in question).

It’s conditional within the code, so Firefox et al won’t run the code — but it doesn’t hurt to wrap it in an IE conditional call to reduce the http pulls for other browsers:

<!--[if IE]>
<script src="html5.js" type="text/javascript"></script>
  1. (function(){if(!/*@[email protected]*/0)return;var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while (i--){document.createElement(e[i])}})()

Report this snippet  

You need to login to post a comment.