By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,625 Members | 1,716 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,625 IT Pros & Developers. It's quick & easy.

Need to detect Safari Browsers

P: n/a

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

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

Jul 23 '05 #2

P: n/a
Nitronic wrote:

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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #3

P: n/a

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

Jul 23 '05 #4

P: n/a
Nitronic <na@na.ca> wrote in message news:<36*********************@news.cogeco.ca>...
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.

--
Rob.
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.