jQuery Browser Detection

Events happening in the community are now at Drupal community events on www.drupal.org.
anthonyvz's picture

Hey Everyone,

Here's the jQuery to detect browser version. This one would look for Internet Explorer 6 and add a css style to "SOME-UNIQUE-ID"

if (jQuery.browser.msie) {
if(parseInt(jQuery.browser.version) == 6) {
$('#SOME-UNIQUE-ID').css('property','value');
}
}

It will detect;
* safari
* opera
* msie
* mozilla

Hopefully you can put that to use. I'm in the process of trying to get it to detect if the user is on an iPhone or not.

Cheers,

Anthony

Comments

just be careful, people that

gavinblair's picture

just be careful, people that use ie6 don't necessarily have javascript enabled. suckers for punishment...

when's our next meeting?

gav

Oh god how did this get in here I am not good with computers

True, but...

mandclu's picture

I'd be surprised if there are many people out there without JS turned on, since I know a lot of sites require it. All the Yahoo sites pretty much require JS, for instance. But it is a good point, we should always try to build sites that degrade gracefully for those without JS.

As for the next meeting, the plan is for the third Wednesday, which would be Feb 18.

jQuery detect iphone

uzbekjon's picture

You can also detect if your site is being visited on iphone.

Here we go detecting iPhone with jQuery:

function isiPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}
if(isiPhone()){
    // Iphone users :))
}

I'm sorry uzbekjon, i try

popoox's picture

I'm sorry uzbekjon, i try your tips and it doesn't work for me. Are you sure about the syntax ?

Best regards

Popoox

London, Ontario

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: