469,646 Members | 1,567 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Firefox/ie issue with img src update?

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

Jan 24 '07 #1
2 3006
"David Housman" <dh******@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
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
Jan 24 '07 #2
-Lost said the following on 1/24/2007 1:14 AM:
"David Housman" <dh******@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
>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>
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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Olivier Verdin | last post: by
8 posts views Thread by Matt Kruse | last post: by
2 posts views Thread by Andy | last post: by
3 posts views Thread by Alexander Higgins | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.