tags:

views:

482

answers:

3

Is it possible to turn off (or hide) the jQuery elements if the user's browser is Safari?

Basically I'm using jquery drop shadow and it doesn't play nice in Safari, but it works well on the other browsers. I'd like to keep the effect, but have it turned off (or hidden) in Safari.. Is this possible?

+4  A: 

This is possible using $.browser:

if(!$.browser.safari) {
    // enable drop shadow or whatever
}

Please note that $.browser is deprecated in jQuery 1.3 and its usage is generally frowned upon. For your purposes, however, I don't think it's particularly evil to use it, just know it's not 100% reliable.

Paolo Bergantino
Thank you so much! That worked perfectly! :)
SoulieBaby
Indeed -- i think i've had a few like that :-/
olliej
+1  A: 

Errr, what's the issue you're seeing with shadows? as they were first implemented in safari it seems surprising that that is the browser that you're seeing problems with. What specifically are you doing?

(and as Paolo said -- browser sniffing is a really really bad idea)

olliej
Basically I have the drop shadow plugin used on the menu and around the "gallery" images on that page, it works in all the other browsers, except for safari..http://www.aurorarestaurant.com.au/gallery
SoulieBaby
SoulieBaby
If you use a browser check you're excluding that browser permanently for no reason other than it's name. Imagining that this is a bug in webkit (rather than a bug in the js which is what i would assume it is based on prior experience) then in the future apple fixes that bug, but safari users still won't get the shadows (or whatever). More over if it is a safari bug, then it's really a bug in webkit (the engine that apple writes for safari), and so will impact all browsers that embed webkit but you won't block them, eg. Arora, Android and Chrome, Epiphany, the Pre, Kindle.. (it's a long list)
olliej
Oh ok.. thanks :)Well I noticed with Safari, it kills the drop shadows on the page if you go to it directly or do a hard refresh, but if you click on one of the other menus and click on the gallery menu again, it fixes itself?! :/
SoulieBaby
If you can file a bug at http://bugs.webkit.org that would be great :D
olliej
not a problem :)
SoulieBaby
+1  A: 

the fact that safari loads ok the second time, and breaks when you refresh, might be an image without size issue. If dropShadow is called on domReady it will not know the size of the image the first time. The second time, the image will be cached and the shados will work ok.

lucascaro