Page 1 of 1

html5 for lte IE8

PostPosted: Tue Apr 26, 2011 12:12 am
by mapleleaf

For those of you interested here is a JavaScript function that will give lte IE8 html5 elements
Code: Select all

<!--[if IE]>
<script>
(function(){
var html5elments = "address|article|aside|audio|
canvas|command|datalist|details|dialog|
figure|figcaption|footer|header|hgroup|
keygen|mark|meter|menu|nav|progress|
ruby|section|time|video".split('|');
for(var i = 0; i < html5elmeents.length; i++){
document.createElement(html5elments[i]);
}
}
)();
</script>
<![endif]-->


Place the above code just above the closing head element in your html.

Previously, I had mentioned the following code that will accomplish the same result. Which method IF you choose to use is entirely your choice.
In either case, you MUST have the following doctype declared
<!DOCTYPE html>

Code: Select all
<!--[if IE]>
          <script>
            document.createElement("header" );
            document.createElement("footer" );
            document.createElement("section");
            document.createElement("aside"  );
            document.createElement("nav"    );
            document.createElement("article");
            document.createElement("hgroup" );
            document.createElement("time"   );
          </script>
          <noscript>
             <strong>Warning !</strong>
             Because your browser does not support HTML5, some elements are simulated using JScript.
             Unfortunately your browser has disabled scripting. Please enable it in order to display this page.
          </noscript>
   <![endif]-->