I want to prevent some parts of my javascript written with jQuery, if it matters, from executing in IE6. What are the preferred methods for doing this?
Thanks!
You can use conditional comments to define a variable and check if it is set at runtime.
Syntax <!--[if IE 6> <script ... /><![endif]--> . The content of the comment is invisible to all other browsers, so it is really reliable.
<!--[if IE 6> <script ... /><![endif]-->
Since you mentioned jQuery why not use the " if ($.browser.msie " construct . I think this resource will be useful to you
if ($.browser.msie
As per your stated goal, you should use Progressive Enhancement instead of browser detection.
You just need to use browser detection script and condition on IE6 so your scripts won't run. here's a link to browser javascript detection .