473,762 Members | 8,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I identify Safari?

Hi to everyone? Can someone tell me if there is a way to identify
Safari...I found out that navigator.appNa me returns "Netscape" and I
didn't found any option to change the browser's definition...
I can use document.all for IE, and so on but what can I do with Safari?
I need to distinguish Safari from other browsers...

Thanks to everyone.
Jul 23 '05 #1
8 3788
Giuseppe Chielli wrote:
Can someone tell me if there is a way to identify Safari...
Reliably? I doubt you can. Why do you want to, anyway?
[...] I can use document.all for IE
No, you can't. Opera and IceBrowser both support the all collection.
Other user agents might, too.
I need to distinguish Safari from other browsers...


I very much doubt that. Your time would probably be better spent
learning how to implement feature detection. See section 4.26 of the
group FAQ, and its linked articles.

Mike
Jul 23 '05 #2
Giuseppe Chielli wrote:
Hi to everyone? Can someone tell me if there is a way to identify
Safari...I found out that navigator.appNa me returns "Netscape" and I
Safari can masquerade as many browsers, you can't reliably identify
it (nor most browsers) using appName.
didn't found any option to change the browser's definition...
A Safari user can change the user agent that Safari masquerades as,
but you, as an HTML/script author, can't.
I can use document.all for IE, and so on but what can I do with Safari?
Changing the browser that Safari pretends to be will not change its
support (or lack thereof) for Microsoft's proprietary (but sometimes
copied) document.all. There are DOM methods that provide the same
functionality that are implemented across a much wider range of
browsers, including Safari.

IE 6 implements pretty much all of them, IE 5 does most and 4 quite a
few. There are simple ways to allow for both MS proprietary and DOM
interfaces - read the FAQ:

<URL:http://www.jibbering.c om/faq/>
I need to distinguish Safari from other browsers...
You haven't provided any reasonable reason for needing to do so.

Thanks to everyone.


No problem. :-)

--
Fred
Jul 23 '05 #3
Michael Winter wrote:
Reliably? I doubt you can. Why do you want to, anyway?


Because I need to prevent the bug of not getting window.innerWid th
property when a document is loaded in a frame... I see now that I can
test if this property is null or undefined... I just had to pay more
attention... ;)
Thanks anyway.

Giuseppe
Jul 23 '05 #4
Fred Oz wrote:
You haven't provided any reasonable reason for needing to do so.


I told about that in a post and now I'll explain it better: I have a GIS
web application and the map image is in a frame; when the window is
resize, the Javascript code works for arranging the size of the image
and it does it using window.innerWid th property.
Because of a bug, in Safari this property doesn't return the correct
value if a document is loaded in a frame (it works properly only without
frames) so I'd like to prevent from resizing window when Safari is used.
I hope to have been clear...

Thanks.
Jul 23 '05 #5
Giuseppe Chielli wrote:
Fred Oz wrote:
You haven't provided any reasonable reason for needing to do so.

I told about that in a post and now I'll explain it better: I have a GIS
web application and the map image is in a frame; when the window is
resize, the Javascript code works for arranging the size of the image
and it does it using window.innerWid th property.
Because of a bug, in Safari this property doesn't return the correct
value if a document is loaded in a frame (it works properly only without
frames) so I'd like to prevent from resizing window when Safari is used.
I hope to have been clear...

Thanks.


A solution was posted by RobB on 11 April that may help, search
this group for "Window size via Javascript for Safari (Mac)" or
follow this:

<URL:http://groups-beta.google.com/group/comp.lang.javas cript/browse_frm/thread/49b992a0042f308 5/7563a3defc6e941 8?q=safari+ifra me+innerwidth&r num=1#7563a3def c6e9418>

(please repair wrapping if required...)

Post again if you need more help with it.

--
Fred
Jul 23 '05 #6
Fred Oz wrote:
Giuseppe Chielli wrote:
Fred Oz wrote:
You haven't provided any reasonable reason for needing to do so.

I told about that in a post and now I'll explain it better: I have a GIS web application and the map image is in a frame; when the window is resize, the Javascript code works for arranging the size of the image and it does it using window.innerWid th property.
Because of a bug, in Safari this property doesn't return the correct value if a document is loaded in a frame (it works properly only without frames) so I'd like to prevent from resizing window when Safari is used. I hope to have been clear...

Thanks.


A solution was posted by RobB on 11 April that may help, search
this group for "Window size via Javascript for Safari (Mac)" or
follow this:

<URL:http://groups-beta.google.com/group/comp.lang.javas cript/browse_frm/thread/49b992a0042f308 5/7563a3defc6e941 8?q=safari+ifra me+innerwidth&r num=1#7563a3def c6e9418>
(please repair wrapping if required...)

Post again if you need more help with it.

--
Fred


Just fyi, you shouldn't need to fetch the 'pre-document' from the
server; a locally assembled one should do:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/str*ict.dtd">
<html>
<head>
<style type="text/css">

iframe {
display: block;
width: 500px;
height: 400px;
margin: 100px auto;
overflow: auto;
}

</style>
<script type="text/javascript">

function if_dummy(redir_ url)
{
//var HTML = '<body onload=location ="@"></body>'; <-- use this
var HTML = '<body
onload=setTimeo ut(\'location=" @"\',1000)>wait </body>'; /* demo only */
return HTML.replace(/@/, redir_url);
}

</script>
</head>
<body>
<iframe
src="javascript :parent.if_dumm y('http://www.google.com' )"></iframe>
</body>
</html>

[untested]

Jul 23 '05 #7
Make that...

function if_dummy(redir_ url)
{
var HTML = '<body onload=location .replace("@")></body>';
return HTML.replace(/@/, redir_url);
}

Jul 23 '05 #8
RobB wrote:
Make that...

function if_dummy(redir_ url)
{
var HTML = '<body onload=location .replace("@")></body>'; ^ ^ ^^ ^^ return HTML.replace(/@/, redir_url);
}


Don't. It is not supposed to work and it is inefficient.
Make it

function if_dummy(redir_ url)
{
return '<body onload="locatio n.replace(\''
+ redir_url + '\')"><\/body>';
}

If that.
PointedEars
Jul 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
5778
by: DU | last post by:
According to a recent post, it seems that Konqueror 3.1+ and Safari 1.1 support CSS3 opacity style property under a proprietary name: "Support for the CSS3 opacity (using -khtml-opacity) property. Make entire blocks and inlines transparent without resorting to transparent PNGs." http://weblogs.mozillazine.org/hyatt/archives/2003_10.html#004249 Now, I have a demo page which works for MSIE 6 for Windows and Mozilla-based browsers but...
4
6015
by: Bernard | last post by:
Hi, I am suddenly getting Safari script errors with the following user agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8 In a frameset scenario, the framesetting document (top) contains a
2
1982
by: jdlwright | last post by:
Hi, I have a big script that doesn't work in Safari 1.3, but does work in FF, and IE. I've given up going to my local Uni. to use their Macs (they've prevented the Debug menu from appearing after running that widely known hack), and so I want to buy my first Mac to do this properly. Being a PC person I am generally ignorant of Mac OS issues;
4
2729
by: Paul W | last post by:
Hi - can someone point me to info on the issues/resolutions of supporting the safari browser? To help me understand, if I was developing pages in say FrontPage, what attributes would I set for 'target browser'? I'm having a helluva time with table layouts etc and goin' stir crazy.. Thanks, Paul.
5
2618
by: Bill Cohagan | last post by:
I'm having some serious difficulties with my ASP.Net 2.0 app rendering in Safari 2.0.3. The most immediate problem is that the menu control doesn't seem to work at all, particularly the use of dynamic levels. I've Googled around a bit and determined that the problem is not so much with Safari as it is with ASP.Net inaccurately determining the browser capabilites for that browser. In the 2.0 Framework it appears that browser caps are...
34
3874
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
3
5411
by: Jeff Paffett | last post by:
I'm trying to use the onPaste event in a text input, which according to Apple is supported. However, I get no response in Safari. Firefox works fine.
21
4426
by: Edward | last post by:
Hi All, I feel frustrated with one of my Customers who wants me to ensure that a dotnet web site I am building for them must be compatible to Apple's Safari browser! Safari is buggy and it does not support lots of things (xhtml etcc). However, what puzzles me is that there are some dotnet Framework 2 web sites out there that work perfectly well under Safari, whereas my website does not
7
7297
by: Nithu25 | last post by:
Hi All, I am facing one issue related to session. Suppose the user closes the window without Logging out, in firefox and in Safari (Mac OS) , the user will be automatically logged in,when they open a new window or a new tab. Is there any way to identify the event of closing the window or tab, opening a new window or tab using javascript, evenif its opened using mouse or keyboard? If any one know the solution, kindly help me....
0
9554
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
9989
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
9927
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
9812
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...
0
6640
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
5268
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
3914
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
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.