473,830 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=nav igator.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 17646
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.javas cript 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=nav igator.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.appVe rsion reports:
5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/85.8.5 (KHTML,
like Gecko) Safari/85.8.1

navigator.userA gent 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
5032
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 ? http://212.186.20.12/www.xenonlights.com/
13
1804
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. Obviously, there are a LOT of older browsers still out there that don't support css and some newer one's that still don't support it very well. Knowing that, I have prepared a second set of pages using table layouts for those browsers. It...
2
1828
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. Something like: __EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=dDwxOTk2NDc2Nzk0OztsPFQ<more stuff cut out>hM%3d&T%3aH%3aR%3aAToken=&T%3aH.... As you may see, the arguments after viewstate are just a mess. The browser seems to be escaping stuff it...
2
1627
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 access the web service works across IE, Firefox and other browsers Does anybody know if they are libraries out there that do this?
16
2524
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 they should, and do in Dotnet. The page is really, really simple, and it has a CSS and with NO masterpage. I have tried using the following as recommendations made earlier in this Newsgroup:-
10
2850
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 library but with less features and code. The Yahoo! event library is one of the best libraries in YUI but it still seems to me to have some confused code...that or I'm still confused. The Yahoo! UI library focuses on using addEventListener and
9
18186
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 whether it supports playing Flash files or not, If yes it starts playing the Flash file.
1
4433
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 https://wwww.myserver.xyz.com.I need to call other sever which URL ends with same as my server “xyz.com “(https://wwww.otherserver.xyz.com) The below mentioned code is working fine only in IE browser, But it is not working in Firefox and Safari...
1
2079
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
9793
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10774
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10489
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6950
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.