Referencing Google's Html5.js file
<!-- [If Ie]><script src= "Http://html5shiv.googlecode.com/svn/trunk/html5.js" ></script><! [EndIf] -
Copy the code to the Head section, and remember that the head section must be (because IE has to know the element before parsing the element, so the JS file cannot be called elsewhere, otherwise it will fail)
Of course, you can also take the code out of your own eyes:html5.js
/*HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed uncompressed Source:https://github.com/afarkas/html5shiv*/(function(L, f) {functionm () {varA =e.elements; return"string" = =typeofA? A.split (""): A}functionI (a) {varb =N[a[o]]; b|| (b = {}, h++, a[o] = h, n[h] =b); returnB}functionP (A, B, c) {b|| (b =f); if(g)returnB.createelement (a); C|| (c =I (b)); b= C.cache[a]? C.cache[a].clonenode (): R.test (a)? (C.cache[a] =C.createelem (a)). CloneNode (): C.createelem (a); returnB.canhavechildren &&!s.test (a)?C.frag.appendchild (b): b}functionT (A, b) {if(!b.cache) B.cache = {}, B.createelem = a.createelement, B.createfrag = a.createdocumentfragment, B.frag =B.createfrag (); A.createelement=function(c) {return!e.shivmethods?B.createelem (c): P (c, a, b)}; A.createdocumentfragment= function ("H,f", "return function () {var n=f.clonenode (),c=n.createelement;h.shivmethods&& (" + m (). Join (). Replace (/\w+/g,function(a) {B.createelem (a); B.frag.createelement (a); return' C ("' + A + '") ' }) + "); return n}") (E, B.frag)}functionQ (a) {a|| (A =f); varb =I (a); if(E.shivcss &&!j &&!)b.hascss) {varC, d =A; C= D.createelement ("P"); D= D.getelementsbytagname ("head") [0] | |d.documentelement; C.innerhtml= "x<style>article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{ Background: #FF0; color: #000}</style> "; C=D.insertbefore (C.lastchild, d.firstchild); B.hascss= !!C} g||T (a, b); returnA}vark = L.HTML5 | | {}, S =/^<|^ (?: Button|map|select|textarea|object|iframe|option|optgroup) $/I, R=/^ (?: A|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul) $/I, J, O= "_html5shiv", H= 0, N={}, G; (function() { Try { varA = F.createelement ("a"); A.innerhtml= "<xyz></xyz>"; J= "hidden"inchA; varb; if(! (b = 1 = =a.childnodes.length)) {f.createelement (A); varc =f.createdocumentfragment (); b= "undefined" = =typeofC.clonenode | | "Undefined" = =typeofc.createdocumentfragment | | "Undefined" = =typeofC.createelement} g=B}Catch(d) {g= j =!0 } })(); varE ={elements:k.elements|| "Abbr article aside audio BDI canvas data DataList details figcaption Figure Footer Header Hgroup main Mark Meter nav OUTP UT Progress section summary time Video ", Version:"3.6.2pre", Shivcss:!1!==k.shivcss, Supportsunknownelements:g, Shivmethods:!1!==k.shivmethods, type:"Default", Shivdocument:q, Createelement:p, createdocumentfragment:function(A, b) {a|| (A =f); if(g)returna.createdocumentfragment (); for(varb = B | | I (a), C = B.frag.clonenode (), d = 0, E = m (), h = e.length; D < H; d++) c.createelement (E[d]); returnC}}; L.HTML5=e; Q (f)}) ( This, document);
Finally add this paragraph to the CSS:
/*html5*/article,aside,dialog,footer,header,section, Footer,nav,figure,menu{display:block}
Html5.js allows IE (including IE6) to support HTML5 element methods