473,406 Members | 2,356 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,406 software developers and data experts.

Javascript bug in Safari ???

This is my HTML Page containing javascript

---------------------------------------------------
<html>
<head>
<script language="JavaScript">

var isSafari = (agent.indexOf("Safari") != -1); // LINE 1

var myimg = new Object(); // LINE 2

function myfn() { alert("Hello"); }

function writemyfn() {

//myimg = new Object(); // LINE 3

document.write('<a href="javascript:myfn()"');
if (document.images) {
myimg.hi = new Image();
myimg.hi.src = "some.gif";
document.write('onmouseover="document.images.open. src=myimg.hi.src">');
}
document.write('<img name="open" src="some.gif"></a>');
}

</script>
</head>
<body>
<script language=JavaScript>
writemyfn();
</script>
</body>
</html>

---------------------------------------------------

With the above HTML, the image doesn't show on Safari
(running Safari 1.3 (v312) on Mac Mini)

If I remove LINE 1, the image starts displaying correctly.
However, I cannot do that in my actual HTML page.

Other workarounds, are if I change
LINE 2 to "var myimg = null;"
& uncomment LINE3 - then again the image starts
displaying.
Is this a known Bug in Safari? Where can it be reported?

Jul 23 '05 #1
3 1642
Shiva wrote:
var isSafari = (agent.indexOf("Safari") != -1); // LINE 1


Is your variable "agent" defined? Or do you mean the userAgent property
of the navigator object?

var isSafari = (navigator.userAgent.indexOf("Safari") != -1);

Remember, the userAgent string must no show the UA's real name. So
checking for existing properties instead of the userAgent might be better.

Daniel
Jul 23 '05 #2
Daniel Kirsch wrote:
Shiva wrote:
var isSafari = (agent.indexOf("Safari") != -1); // LINE 1
Is your variable "agent" defined? Or do you mean the userAgent
property of the navigator object?

var isSafari = (navigator.userAgent.indexOf("Safari") != -1);


Changing the agent to navigator.userAgent does fix the problem.
Remember, the userAgent string must no show the UA's real name.
I don't understand.
So
checking for existing properties instead of the userAgent might be
better.


Can you elaborate?

Jul 23 '05 #3
Shiva wrote:
Daniel Kirsch wrote:
Remember, the userAgent string must no show the UA's real name.


I don't understand.


Using Firefox or Opera the user is able to change the string returned by
navigator.userAgent.
This was mainly introduced because a lot of developers checked the
browser and it's vendor this way and eg. showed a simple "wrong browser,
you must have InternetExplorer", although the page does actually work
with the latest version of other browsers too.

So
checking for existing properties instead of the userAgent might be
better.


Can you elaborate?


That depends on what you want to do and why you are using this browser
check.

eg. if you want to use the all collection from InternetExplorer to
access elements, you may not check for InternetExplorer, but check for
the all collection as other browsers may also implent it or a new
version of InternetExplorer will not support it anymore (which I doubt)
and the userAgent string must not be correct:

function getElm(id) {
if (document.all)
return document.all[id];
else if (document.getElementById)
return document.getElementById(id);
return null;
}

Daniel
Jul 23 '05 #4

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

Similar topics

5
by: joaopedrogoncalves | last post by:
Hi, I want to load an external javascript file, get its results and stick them inside a <div> block. I also want to do this in several places on a web page. This way the browser doesn't have...
3
by: Joe Cox | last post by:
I am having a problem with style properties for dynamic images in Mac OS X Safari. By dymanic images, I mean images allocated with the javascript 'new Image()' call. With static images (created...
7
by: petermichaux | last post by:
Hi, I have tried the following based on suggestions of the best way to insert JavaScript into a page. This is instead of using eval(). Unfortunately IE says "unexpected call to property or...
14
by: maidane | last post by:
Hi, I got the following situation using the AC_Quicktime library. Apple recommend to use a Javascript call to generate the OBJECT tag (http://developer.apple.com/internet/ieembedprep.html). I...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
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...

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.