Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old January 24th, 2007, 04:55 AM
David Housman
Guest
 
Posts: n/a
Default 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

  #2  
Old January 24th, 2007, 06:15 AM
-Lost
Guest
 
Posts: n/a
Default Re: Firefox/ie issue with img src update?

"David Housman" <dhousman@gmail.comwrote in message
news:1169613980.256687.128850@h3g2000cwc.googlegro ups.com...
Quote:
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


  #3  
Old January 24th, 2007, 01:25 PM
Randy Webb
Guest
 
Posts: n/a
Default Re: Firefox/ie issue with img src update?

-Lost said the following on 1/24/2007 1:14 AM:
Quote:
"David Housman" <dhousman@gmail.comwrote in message
news:1169613980.256687.128850@h3g2000cwc.googlegro ups.com...
Quote:
>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/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.