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?
You can try http://api.jquery.com/jQuery.browser/ :)
I don't know about jQuery, but you could prevent the code from running using Conditional Comments
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
}
精彩评论