Html5shiv allows IE to support HTML5-tagged JavaScript compatibility libraries

Source: Internet
Author: User

How to use

The author has put this code on Google Code project, but because Google can't access it, just call the code in your head tag.

<!–if lt IE 9]><script src= "Js/html5shiv.js" ></script><!–endif]–>

Of course, you can also download this file directly to your website. This file must be called in the head tag, because IE must know these elements before parsing the element to start the action! you may also want to add the following code to your CSS file, otherwise there might be some inexplicable problems.

Header,nav,article,section,aside,footer{display:block;}

In addition Excanvas.js is Google for the IE6 support canvas elements written script, there are very detailed examples, interested friends can go to try.

Html5shiv principle

The better solution for IE browser is Html5shiv. Html5shiv Main solution HTML5 proposed new elements are not recognized by ie6-8, these new elements cannot wrap child elements as parent nodes, and CSS styles cannot be applied. It is possible to apply CSS styles to unknown elements by simply performing document.createelement (elementname). Html5shiv is created based on this principle.

HTML5 Shiv is able to use HTML5 newly added elements to be compatible with older versions of Internet Explorer browsers, HTML5 Shiv is compatible with Internet Explorer 6-9, Safari 4.x (and IPhone 3.x), and Firefox 3.x and other browsers.

Project Document Introduction Html5shiv.js

This includes basic createElement() core technologies, calls to Ie6-8, document.createElement and browsers that are document.createDocumentFragment  compatible with ie6-9, Safari 4.x and FF 3.x.

Html5shiv-printshiv.js

This includes all of the above, and is also a mechanism that allows the HTML5 element to be displayed normally on the browser of IE 6-8 as a contained child element.

HTML5 Shiv API

HTML5 Shiv as a simple compatibility library. In most cases, you do not need to configure HTML5 Shiv or use a method that is provided with HTML5 Shiv.

html5.elementsOption

elementsthe option is a space separated string or array, which describes the full list of the elements to Shiv. Also addElements .

Configuring elements before is html5shiv.js included.

Create a global HTML5 options OBJECTWINDOW.HTML5 = {  ' elements ': ' Mark section customelement '};

Configuring after IS elements html5shiv.js included.

Change the Html5shiv options object window.html5.elements = ' Mark section customelement ';//and re-invoke the ' Shivdocume NT ' methodhtml5.shivdocument (document);
html5.shivCSS

If shivCSS true is set to HTML5 Shiv would add basic styles (mostly Display:block) to sectioning elements (like section, AR ticle). In most cases a webpage author should include those basic styles in his normal stylesheet to ensure older browser support (i.e. Firefox 3.6) without JavaScript.

shivCSSthe is true by default and can are set false, only before Html5shiv.js is included:

Create a global HTML5 options OBJECTWINDOW.HTML5 = {    ' shivcss ': false};
html5.shivMethods

If The shivMethods option is set to true (by default) HTML5 Shiv would override document.createElement /in document.createDocumentFragment Internet Explorer 6-8 to allow dyn Amic DOM creation of HTML5 elements.

Known issue:if an element was created using the overridden createElement method This element returns a document fragment as its , but should was normally null . If a script relies on this behavior, shivMethods should is set to false . Note:jquery 1.7+ has implemented he own HTML5 DOM creation fix for Internet Explorer 6-8. If all your scripts (including third party scripts) is using JQuery ' s manipulation and DOM creation methods, you might WA NT to set the This option to false .

Configuring shivMethods before is html5shiv.js included.

Create a global HTML5 options OBJECTWINDOW.HTML5 = {    ' shivmethods ': false};

Configuring after IS elements html5shiv.js included.

Change the Html5shiv options object window.html5.shivMethods = false;
html5.addElements( newElements [, document] )

The html5.addElements method extends the list of elements to Shiv. The newelements argument can be a whitespace separated list or an array.

Extend list of elements to shivhtml5.addelements (' element content ');
html5.createElement( nodeName [, document] )

html5.createElementThe method creates a shived element, even if is shivMethods set to false.

var container = html5.createelement (' div ');//container is shived so we can add HTML5 elements using ' InnerHTML ' container.i nnerhtml = ' <section>this is a section</section> ';
html5.createDocumentFragment( [document] )

html5.createDocumentFragmentThe method creates a shived document fragment, even if is shivMethods set to false.

var fragment = Html5.createdocumentfragment (), var container = document.createelement (' div '); Fragment.appendchild ( Container)//fragment is shived so we can add HTML5 elements using ' innerHTML ' container.innerhtml = ' <section>this i s a section</section> ';

GitHub Address: Https://github.com/aFarkas/html5shiv

This article is to ask the author of the network to ask the network published, and asked the Web editor, reproduced please indicate the source and this article link. This site is reproduced in addition to the article, are the original site or translation, welcome any form of reprint, but please be sure to indicate the source, respect for the work of others.
Reprint Please specify: The article reprinted from: Ask said net»html5shiv let IE also can support HTML5 label JavaScript Compatibility library
This article title: Html5shiv allows IE to also support the JavaScript Compatibility library for HTML5 tags
This address: http://www.uedsc.com/use-html5-for-ie.html

Html5shiv allows IE to support HTML5-tagged JavaScript compatibility libraries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.