Firefox/ie issue with img src update?

D

David Housman

Hello,

Though this came up in the act of learning js, I'm not actually sure
this is a js question. I can write and call a function to update the
src of an image. But in Firefox the image quickly reverts back to the
original one. In IE it seems to work properly.
I boiled this down to the following lines:

<img name = "myImage" src = "script/images/balloon.gif" width="106"
height="131">
<a href
onClick="document.myImage.src='script/images/heron.gif'"))>heron!</a>

If this isn't a js question, I'd appreciate it someone could point me
in the right direction. Thanks in advance for your understanding and
assistance.

Thanks again,
Dave
 
L

-Lost

David Housman said:
Hello,

Though this came up in the act of learning js, I'm not actually sure
this is a js question. I can write and call a function to update the
src of an image. But in Firefox the image quickly reverts back to the
original one. In IE it seems to work properly.
I boiled this down to the following lines:

<img name = "myImage" src = "script/images/balloon.gif" width="106"
height="131">
<a href
onClick="document.myImage.src='script/images/heron.gif'"))>heron!</a>

If this isn't a js question, I'd appreciate it someone could point me
in the right direction. Thanks in advance for your understanding and
assistance.

Thanks again,
Dave

Hrmm... no clue if this is the culprit, but why is there 2 parenthesis after the event
handler?

<a href="heron.htm" onclick="document.myImage.src='script/images/heron.gif'; return
false;">heron!</a>

-Lost
 
R

Randy Webb

-Lost said the following on 1/24/2007 1:14 AM:
Hrmm... no clue if this is the culprit, but why is there 2 parenthesis after the event
handler?

<a href="heron.htm" onclick="document.myImage.src='script/images/heron.gif'; return
false;">heron!</a>

The issue was with the lack of a return false in the event handler. The
onclick fires, the image gets changed, the href gets followed and
Firefox is reloading the page so that it goes back to the original image.
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top