Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
744 views
in Technique[技术] by (71.8m points)

internet explorer - How to detect IE7 and IE8 using jQuery.support

How can I detect IE 7 and IE 8 using jQuery.support properties?

Is it possible to detect the browser versions using jQuery.support or just those blah blah blah browser features?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is totally possible with support:

if (!$.support.leadingWhitespace) {
    //IE7 and 8 stuff
}

This also detects IE 6 however, if you don't want IE 6 to run this code block, you will need another flag to exclude it

A good reason for not using browser is it is a deprecated feature, and it will likely be removed to a plugin with version 1.9. (See the comments on the answer to How to detect IE7 with jQuery?)

"We recommend against using this property; please try to use feature detection instead (see jQuery.support). jQuery.browser may be moved to a plugin in a future release of jQuery" http://api.jquery.com/jQuery.browser/

here is a working example: http://jsfiddle.net/AGtG8/16/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...