Mild Fuzz
Mild Fuzz

Reputation: 30681

exclude IE7 from a piece of jQuery?

I seem to have a problem with some jQuery, and I can't figure out where I am going wrong so I just want to take ie7 out of the equation by excluding it, can this be done with jQuery?

Upvotes: 0

Views: 691

Answers (3)

Dr.Molle
Dr.Molle

Reputation: 117334

if you need the detection inside a script(conditional comments are HTML-comments), you can detect it by checking some properties.

var ie7 = (document.all && !window.opera && window.XMLHttpRequest && typeof window.external.AddToFavoritesBar=='undefined') ? true : false;
var ie7mode = (document.all && !window.opera && window.XMLHttpRequest && !document.querySelectorAll) ? true : false;

inside a script you can use it like this:

if(!ie7mode)
{
  //this will be ignored in IE7 or higher versions running in IE7-mode
}  
if(!ie7)
{
  //this will be ignored in IE7 only
}  

Upvotes: 0

Peter T. LaComb Jr.
Peter T. LaComb Jr.

Reputation: 2975

I don't know about jQuery, but you could prevent the code from running using Conditional Comments

Upvotes: 1

Claudiu
Claudiu

Reputation: 3261

You can try http://api.jquery.com/jQuery.browser/ :)

Upvotes: 1

Related Questions