HTML5 compatibility for browsers earlier than IE9

Source: Internet
Author: User
Tags html header

Comments: To enable IE (including IE6) to support HTML5 elements, you must add a simple document in the HTML header. createElement declaration. For details, refer to this article to allow IE (including IE6) to support HTML5 elements. We need to add the following JavaScript in the HTML header, which is a simple document. createElement declaration. This js file is called for IE using conditional annotations. Opera, FireFox, and other non-ie browsers will ignore this code and there will be no http requests.

The Code is as follows:
<! -[If IE]>
<Script src = "http://html5shiv.googlecode.com/svn/trunk/html5.js”> </script>
<! [Endif]->

The above code will only run in IE browser. Note that calling the html5.js file on the page must be added to the Header element of the page, because IE browser must know this element before parsing the element, this js file cannot be called at the bottom of the page.
This html5 js file is provided by the author on the Google code project for direct calls. Of course, if you think this will affect your webpage opening speed, you can download html5 js files and upload them to your server for separate calls.
The following is the code in the html5 js file:

The Code is as follows:
(Function () {if (! /* @ Cc_on! @ */0) return; var e = "abbr, article, aside, audio, canvas, datalist, details, dialog, eventsource, figure, footer, header, hgroup, mark, menu, meter, nav, output, progress, section, time, video ". split (','), I = e. length; while (I-) {document. createElement (e [I]) }}) ()

In addition to calling js files containing the above Code on the webpage to allow IE to support HTML5 elements, you can add the Code directly to the webpage in the following way.

The Code is as follows:
<! -[If IE]>
<Script>
(Function () {if (! /* @ Cc_on! @ */0) return; var e = "abbr, article, aside, audio, canvas, datalist, details, dialog, eventsource, figure, footer, header, hgroup, mark, menu, meter, nav, output, progress, section, time, video ". split (','), I = e. length; while (I-) {document. createElement (e [I]) }}) ()
</Script>
<! [Endif]->

Related Article

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.