HTML5 shiv--solution for IE (IE6/IE7/IE8) incompatible HTML5 label method

Source: Internet
Author: User

HTML5 's semantic tags and attributes make it easy for developers to implement clear Web page layouts. Most browsers are basically compatible with HTML5, but for now IE6/IE7/IE8 are not compatible with HTML5 tags, so javascript processing is required to make them compatible

Method One: JavaScript code

<!--[if Lt ie9]> <script>   (function () {   if (!/*@[email protected]*/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 (', ');  var i= e.length;   while (i--) {    document.createelement (E[i])   }  ) () </script><![ Endif]-->

If the IE browser below IE9 will create the HTML5 tag, then the non-IE browser will ignore this code, there will be no unnecessary HTTP requests.

Method two: Using Google's Html5shiv package

<!--[if LT ie9]> <script src= "Http://html5shiv.googlecode.com/svn/trunk/html5.js" ></script><! [endif]-->

(PS: The page that opens the link needs fq, in addition even if I fq, open the webpage shows is no dialers left to try on pass 0)

Due to the domestic Google Server access card, it is recommended to call the domestic CDN

<!--[if LT IE 9]><script src= "Https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js" ></script ><! [endif]-->

The link pro-test is available

JS part is finished, but there is a small problem, if you encounter ie6/7/8 disabled script users, then become a no-style "Whiteboard" page, how can we solve it?

We can refer to Facebook's practice of directing users to the "/?_fb_noscript=1" page with the NoScript logo, replacing HTML5 tags with html4 tags, which is lighter than writing a lot of hack to keep compatibility.

<!-- [If LTE IE 8]> <noscript>   <style>.html5-wrappers{display:none!important;} </style>   <div class= "ie-noscript-warning" > your browser has disabled the script, please <a href= "" > View here </a> to enable the script! or <a href= "/?noscript=1" > continued access to </a>.   </div></noscript><! [EndIf]  -

This can lead the user to open the script or jump directly to the interface of the HTML4 label design.

JS part solved, to the CSS section. CSS needs to initialize these new elements to facilitate layout settings

  

Note: Good memory is better than bad writing, summed up the development will encounter some practical problems, such as if again encountered can be turned out to see, the content of comparative basis, if there is similar, purely coincidental

HTML5 shiv--How to resolve the HTML5 label for IE (IE6/IE7/IE8)

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.