Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting browser with JQuery

I am trying to use

    jQuery(document).ready(function () {
        if (!jQuery.browser.msie <= 7.99) {
                jQuery('#element').css('display', 'block');
        }
    });

But it doesn't appear to work ? What am I doing wrong ?

Thx

Edit: Use conditional comments

<!--[if !IE]>
<!--[if lt IE 8]> 

//do stuff
<![endif]-->
<![endif]-->
like image 663
Tom Avatar asked Jul 19 '10 17:07

Tom


1 Answers

jQuery.browser.version is what you're looking for. And you should probably parseFloat it.

In general though, it's looked down upon to rely on browser sniffing unless there's absolutely no way to feature detect. It might help telling us what your real problem is.

EDIT: You should use conditional comments to serve rules/stylesheet(s) for IE7 and below.

like image 118
meder omuraliev Avatar answered Oct 05 '22 05:10

meder omuraliev