Monday 26 December 2011

Detect Internet Explorer using jquery

If you love jQuery like I do then here is the simple snippet that you can use to detect browser.
 
if (jQuery.browser.msie) {
    // do sth.
}
 
For detecting a specific version of Internet Explorer only: 
 
// Select Internet Explorer above 6
if (jQuery.browser.msie && jQuery.browser.version > 6) {
    // do sth.
}
 
// Select Internet Explorer 7 and below
if (jQuery.browser.msie && jQuery.browser.version <= 7) {
    // do sth.
}
 
// Select just Internet Explorer 6
if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
    // do sth.
}
 
// Select just Internet Explorer 7
if (jQuery.browser.msie && jQuery.browser.version == '7.0') {
    // do sth.
}
 
// Select just Internet Explorer 8
if (jQuery.browser.msie && jQuery.browser.version == '8.0') {
    // do sth.
}
 
// Select just Internet Explorer 9
if (jQuery.browser.msie && jQuery.browser.version == '9.0') {
    // do sth.
}
 

No comments:

Post a Comment