Question

What would be the best way of disabling jquery on an unsupported browser eg IE5.5. I just want to turn the errors off; I'm not trying to get it to work 100% properly or anything just to stop throwing errors; that's if it's not that big of a deal. If it is very difficult to do then I'm not that bothered.

Was it helpful?

Solution

Use the HTML5 Boilerplate method to add a class to your html tag if the IE version is less than 6:

<!--[if lt IE 6]> <html class="ie5" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->

Then put an if right at the top of your JS:

if ($('html.ie5').length !== 1) {
  // do stuff
}

Edit

Should have thought of this! Rather than doing that, just use the H5BP method when including your JS files:

<!--[if gte IE 6]><!-->
  <script src="jquery.js" text="text/javascript"></script>
  <script src="application.js" text="text/javascript"></script>
<!--<![endif]-->

This delivers the JS files to IE6+ and all other browsers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top