Need to detect Safari Browsers

N

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 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;
}
}
 
U

unruly

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.
 
R

Randy Webb

Nitronic said:
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-->
 
N

Nitronic

Thanks for the help. Guys keep sending posts if u have any other ideas :)

Hello Nitronic,
 
R

RobG

Nitronic said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top