473,803 Members | 4,392 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 17644
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
5028
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
1801
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
1825
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
1624
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
2522
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
2849
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
18185
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
4431
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
9699
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
10542
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
10309
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
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7600
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
5496
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...
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.