Html5.js enables IE (including IE6) to support HTML5 Element Methods

Source: Internet
Author: User
Tags html header

Address: http://blog.sina.com.cn/s/blog_62a36ec401018oqb.html

Html5.js enables IE (including IE6) to support HTML5 Element Methods

Microsoft's latest IE 8 browser and earlier versions have limited support for HTML5 labels. We can add scripts to webpages to solve the HTML5 Support Problem of IE browser.

To enable IE (including IE6) to support HTML5 elements, we need to add the following JavaScript in the HTML header. This is a simple document. createElement_x declaration that uses conditional annotations to call this js file for IE. Opera, FireFox, and other non-ie browsers will ignore this code and there will be no http requests.

<! -[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:

(Function () {if (! 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_x (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.

<! -[If IE]>
<Script>
(Function () {if (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_x (e [I])}) ()
</Script>
<! [Endif]->

The IE Development Manager, Adrian Bateman, once said that the IE team wanted to share their views on HTML5 and participate in the discussion on developing this standard. Although the IE Team currently raises more questions than provides a solution, public discussion is the best way to promote HTML5 development.

Html5.js enables IE (including IE6) to support HTML5 Element Methods

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.