473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need to detect Safari Browsers


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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rolf Brauser | last post by:
Hi, I canīt manage to change the a.hover text color on Mac IE or Safari browsers .. If I attache textdecoration for example it matches. why is that ? ...
13
by: ima | last post by:
I've been studying a great book on css and now that I've put together a few pages using it, I'm finding out that my book needed one more very important chapter. Introducing css in the real world. ...
2
by: Max Metral | last post by:
I get sporadic viewstate errors from Macintosh browsers. I get mailed the form values when this happens, and it appears that the problem is the encoding of the POST value from the browser. ...
2
by: ilyas | last post by:
Hi all I have a web service that I have written. It is written in C# I want to use this web service from a browser, but my users all have different browsers so its important that the code to...
16
by: Edward | last post by:
Hi All, I am having huge problems with a very simple dotnet framework web page (www.gbab.net/ztest3.aspx) , it does NOT render correctly under Apple's Safari. The DIV's do not align amd float as...
10
by: Peter Michaux | last post by:
Hi, Today I have been testing the event models from Netscape 4.8 and IE 4 to the current crop of browsers. I'd like to write a small event library similar in purpose to the Yahoo! UI event...
9
by: Anees | last post by:
Hi friends.. i know it may be a repeated Q. Though i had search across i couldnt get the right solution and in some, links were broken.. I want to check a browser when a user clicks on a link...
1
by: saravj2ee | last post by:
Hi, I have implemented prototype.js file to use AJAX calls in my application. I need to call cross domain to get some value from different server. The HTML and prototype file are hosted in...
1
by: Chetana | last post by:
Hi , I want to allow popups automatically from asp.net program for browser. Is it possible? If yes how it can be done? Please reply me immidiately... Thanks.
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.