开发者

How to disable scripts for ie6 inside your html code

i've been using jquery succesfully with almost any browser but ie6, i'm giving up i wish i could use a conditional statement like

  <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="css/style-for-ie.css" media="screen" />
  <![endif]-->

To disable my scripts, is there anyway i can tell ie6 to stop loading something or to disable javascript altogether? or can i make a script.js for jquery that stops ie6 from loading 开发者_C百科certain functions? I'm willing to use php to disable some code in my html if ie6 present, as long as is transparent to the user. Thank you in advance


Use a downlevel-revealed conditional comment to place a class on the <body>:

<!--[if lt IE 7]><body class="ie6"><![endif]-->
<!--[if gte IE 7]><!--><body class="notie6"><!--<![endif]-->

Now you can target selectors at IE6 or not-IE6, from both stylesheets (so you don't necessarily have to use a separate stylesheet) and scripts (either checking the class of document.body manually, or just using selectors like $('body.notie6 div.something') in jQuery).

There are conditional comments directly in JScript too, but, annoyingly, they only target particular JScript engine version numbers, which don't always tie up with IE version numbers. Using the HTML conditional comments for everything makes it more consistent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜