JS in FireFox

S

Shahin

Hi,

The following code works fine in IE, but in Firefox it does not:

<SCRIPT LANGUAGE="JavaScript" > <!--src="change_image.js"> -->
function changeImage(filename,image_id)
{
mainimage.src = filename;
document.getElementById("img1").style.visibility = "hidden";
document.getElementById("img2").style.visibility = "hidden";
document.getElementById(image_id).style.visibility = "visible";
}
</script>

<body>
<div id="img1" class="images_caption"
style="visibility:visible">Hello1</div>
<div id="img2" class="images_caption">Hello2</div>

<div class="images_zoom" >
<img name="mainimage" src="images/jewellery/1.jpg">
</div>

<div class="images_list">
<a href="#" onclick="changeImage('images/jewellery/1.jpg','img1')" >
<img src="images/jewellery/thumb_2.jpg"/></a>
</div>
</body>


Could you please help me to correct the code to become FF
compatible?

Best regards
Shahin
 
R

Randy Webb

Shahin said the following on 3/4/2007 11:24 AM:
Hi,

The following code works fine in IE, but in Firefox it does not:

There is a thread, right now, that is discussing this very issue. You
have fallen into the IE trap of ID'es becoming global variables.
<SCRIPT LANGUAGE="JavaScript" > <!--src="change_image.js"> -->
function changeImage(filename,image_id)
{
mainimage.src = filename;

document.images['mainimage'].src = filename;

Could you please help me to correct the code to become FF
compatible?

"FF compatible"? Why not strive to write cross-browser compatible code?

<URL: http://jibbering.com/faq/index.html#FAQ4_41>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top