Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / March 2005



Tip: Looking for answers? Try searching our database.

Need to detect Safari Browsers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nitronic - 29 Mar 2005 13:30 GMT
I got this javascript code below and each time i got to a safari browser
it thinks its netscpe any ideas.  But i threw in Safari code but it doesn't
work.

var browserName=navigator.appName;
                // Menu offset y coordinate
   
    if (browserName=="Netscape")
    {
         var StartTop=97;                // Menu offset x coordinate
         var StartLeft=-309;   
    }
        //else
        {
            if (browserName=="Microsoft Internet Explorer")
            {   
                   var StartTop=105;                // Menu offset x coordinate
                 var StartLeft=-310;   
            }
            else if (browserName=="Safari")
            {
                    var StartTop=95;                // Menu offset x coordinate
                  var StartLeft=-130;   
             }
        }
unruly - 29 Mar 2005 14:28 GMT
IIRC, Safari's user-agent string contains "compatable".  You might go
digging for that if you want to find them.  It is, of course,
unreliable. However it works in most cases.
Randy Webb - 29 Mar 2005 23:30 GMT
> I got this javascript code below and each time i got to a safari browser
> it thinks its netscpe any ideas.  But i threw in Safari code but it
> doesn't work.

That code doesn't "work" (reliably) in any browser. What browser the
user has is irrelevant. Read this groups FAQ, specifically section 4.26

http://jibbering.com/faq/#FAQ4_26

<--garbage code snipped-->

Signature

Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly

Nitronic - 30 Mar 2005 04:28 GMT
Thanks for the help.  Guys keep sending posts if u have any other ideas :)

Hello Nitronic,

> I got this javascript code below and each time i got to a safari
> browser it thinks its netscpe any ideas.  But i threw in Safari code
[quoted text clipped - 20 lines]
> }
> }
RobG - 31 Mar 2005 10:21 GMT
> Thanks for the help.  Guys keep sending posts if u have any other ideas :)

I can't understand your issue.

navigator.appVersion reports:
5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/85.8.5 (KHTML,
like Gecko) Safari/85.8.1

navigator.userAgent reports:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/85.8.5
(KHTML, like Gecko) Safari/85.8.1

Both strings contain 'Safari'.  Of course, Safari can masquerade as
something else, so your issue isn't always fixed.

Signature

Rob.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.