473,387 Members | 1,904 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,387 software developers and data experts.

Rollover image work in Netscape 7 but not work in Internet Explorer 6

Koh
My rollover image effect work fine in Netscape but not in Internet
Explorer. Is there any important element or tag that I have miss out
so it is not working in Internet Explorer? Below is my code, hope
there is someone can help me. Thank you.

<html>
<head>
<title>List of Products</title>
<script language="JavaScript">
<!--
function swapImage(category)
{
document.getElementById('category').src = eval(category + ".src");
}

FrozenFoodOMO = new Image();
FrozenFoodOMO.src = "FrozenFoodOMO.gif";
FreshFoodOMO = new Image();
FreshFoodOMO.src = "FreshFoodOMO.gif";
BeveragesOMO = new Image();
BeveragesOMO.src = "BeveragesOMO.gif";
HomeHealthOMO = new Image();
HomeHealthOMO.src = "HomeHealthOMO.gif";
PetFoodOMO = new Image();
PetFoodOMO.src = "PetFoodOMO.gif";

-->
</script>
</head>
<body>
<map name="category">
<area shape="rect" coords="0,0,76,60" href="frozen_food.html"
onmouseover="swapImage('FrozenFoodOMO')" target="frame_2">
<area shape="rect" coords="94,0,170,60" href="fresh_food.html"
onmouseover="swapImage('FreshFoodOMO')" target="frame_2">
<area shape="rect" coords="192,0,302,60" href="beverages.html"
onmouseover="swapImage('BeveragesOMO')" target="frame_2">
<area shape="rect" coords="320,0,400,60" href="home_health.html"
onmouseover="swapImage('HomeHealthOMO')" target="frame_2">
<area shape="rect" coords="416,0,495,60" href="pet_food.html"
onmouseover="swapImage('PetFoodOMO')" target="frame_2">
</map>
<img src="Category.gif" id="category" border="0" usemap="#category"
style="position: absolute; top: 0px; left: 0px;">
</body>
</html>
Jul 23 '05 #1
2 1988
Koh
I know which part when wrong. In the img element, I used "category" as
the value for the ID field. This value is conflict with the parameter
name that I used on the swapImage function. Therefore I think the IE
evaluate the category variable in
document.getElementById('category').src, which result failing to
locate the img element. I don't know why Netscape work, but after I
change the conflict value, it work on both browser. Thanks for those
who had help.

<img src="Category.gif" id="category" border="0" usemap="#category"
style="position: absolute; top: 0px; left: 0px;">

function swapImage(category)
{
document.getElementById('category').src = eval(category + ".src");
}

de********@yahoo.com (Koh) wrote in message news:<70**************************@posting.google. com>...
My rollover image effect work fine in Netscape but not in Internet
Explorer. Is there any important element or tag that I have miss out
so it is not working in Internet Explorer? Below is my code, hope
there is someone can help me. Thank you.

<html>
<head>
<title>List of Products</title>
<script language="JavaScript">
<!--
function swapImage(category)
{
document.getElementById('category').src = eval(category + ".src");
}

FrozenFoodOMO = new Image();
FrozenFoodOMO.src = "FrozenFoodOMO.gif";
FreshFoodOMO = new Image();
FreshFoodOMO.src = "FreshFoodOMO.gif";
BeveragesOMO = new Image();
BeveragesOMO.src = "BeveragesOMO.gif";
HomeHealthOMO = new Image();
HomeHealthOMO.src = "HomeHealthOMO.gif";
PetFoodOMO = new Image();
PetFoodOMO.src = "PetFoodOMO.gif";

-->
</script>
</head>
<body>
<map name="category">
<area shape="rect" coords="0,0,76,60" href="frozen_food.html"
onmouseover="swapImage('FrozenFoodOMO')" target="frame_2">
<area shape="rect" coords="94,0,170,60" href="fresh_food.html"
onmouseover="swapImage('FreshFoodOMO')" target="frame_2">
<area shape="rect" coords="192,0,302,60" href="beverages.html"
onmouseover="swapImage('BeveragesOMO')" target="frame_2">
<area shape="rect" coords="320,0,400,60" href="home_health.html"
onmouseover="swapImage('HomeHealthOMO')" target="frame_2">
<area shape="rect" coords="416,0,495,60" href="pet_food.html"
onmouseover="swapImage('PetFoodOMO')" target="frame_2">
</map>
<img src="Category.gif" id="category" border="0" usemap="#category"
style="position: absolute; top: 0px; left: 0px;">
</body>
</html>

Jul 23 '05 #2
Koh wrote:
<img src="Category.gif" id="category" border="0" usemap="#category"
style="position: absolute; top: 0px; left: 0px;">

function swapImage(category)
{
document.getElementById('category').src = eval(category + ".src");
}
eval() is nonsense here (see the FAQ), and the script is
not downwards compatible as well as error-prone. Write

javascript:

var HomeHealthOMO = new Image();
HomeHealthOMO.src = ...;
// ...

function swapImage(oCategory)
{
var imgs = null, cat = null, cat2 = null;
if ((imgs = document.images)
&& (imgCat = imgs['category'])
&& imgCat.src
&& oCategory
&& oCategory.src)
{
imgCat.src = oCategory.src;
}
}

HTML:

<area ... onmouseover="swapImage(HomeHealthOMO)" ...>

or have a look at <http://pointedears.de.vu/scripts/test/hoverMe/> instead.
[Top post]


Please do not do that, see <http://netmeister.org/news/learn2quote.html>
and the FAQ.
PointedEars
Jul 23 '05 #3

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

Similar topics

2
by: Robert Oschler | last post by:
I have a web page where I want to make sure that an image HTTP request is successfully made before the page unloads. The request is made by setting the image element's SRC property to the desired...
5
by: Brian Angliss | last post by:
I'm relatively new to scripting in JavaScript, so I'm not too surprised I'm having difficulty scripting up an animation effect for my personal site. What I'm trying to do is the following: When...
3
by: Max Biancofiore | last post by:
I am working on a website. Can everybody have a look at www.intheloop.org.uk/sw5/index.html and tell me: 1) How long do the buttons take to download. (state connection speed too). 2) How do...
6
by: George Hester | last post by:
Try it. Using Microsoft Internet Explorer 5.5 SP2 (that's the version I am using) in Windows 2000 SP3: In a html put this in: <select type="select-one" id="oSel1"> <option value="1"...
1
by: Max Biancofiore | last post by:
I am working on a new website. Please, can everybody go to www.intheloop.org.uk\sw5\index.html and tell me: 1) How long do the buttons take to download (please, also state connection speed)?...
1
by: John | last post by:
I am rotating images of different dimensions. My problem is that when a new image is displayed in a new position which had an image of a different dimension, the old image is first stretched to the...
9
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
3
by: Becky Carter Hickman-Jones | last post by:
Hi, I have a simple script that opens an image in a new window which is sized to the image. The script is as follows: <a title="xxx"...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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
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...

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.