您的位置:首页 > 其它

3 Solutions for Supporting Internet Explorer

2014-03-29 23:21 225 查看


3 Solutions for Supporting Internet Explorer

Written by David Walsh on February 10, 2014 ·  33
Comments


In the beginning, Internet Explorer was the progressive browser.  After a period of inactivity, Internet Explorer became the bane of our existence.  Microsoft has since recommitted to their browser but the fact remains that sometimes modern Internet Explorer is
lagging just a bit behind WebKit-based browsers and Firefox.  We also need to accommodate for earlier versions of IE.  The following will allow your sites to quickly and almost magically work better in Microsoft's flagship browser!


htmlshiv.js

Remy's HTML5shiv creates HTML5 elements like main, header, footer, etc.
via JavaScript.  Somehow creating said elements via JavaScript communicates that they are styleable.  We can think for days about why it works but who cares?  This crutch is still a must-use on all production sites./

<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
<![endif]-->


selectivizr.js

Selectivizr.js is an incredible resource, polyfilling loads of unsupported CSS selectors
and properties, including the all-important 
last-child
. On a recent redesign,
I was able to plug selectivizr in and not miss a beat in older Internet Explorers. Here's how I implemented it:
<!--[if lte IE 8]><script src="js/libs/selectivizr.js"></script><![endif]-->


An absolute must for your modern projects. Only loaded for old IE's


<html> Conditional Comments

The ugliest conditional comment series you'll ever see.  Ever.  But ugly or not, the fact remains that this code workers exactly as intended:
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9" lang="en"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->


This snippet doesn't require or wait on JavaScript, and isn't near the weight of a JavaScript library.  Your styles for defined classes are immediately enacted and there's no flash of unstyled content.

While Internet Explorer is catching up to its competitors, the fact remains that their old browsers are still relatively popular, especially in developing countries.  The good news is that these resources work in all of those browsers and are not expensive
in modern browsers!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: