Current location: Hot Scripts Forums » General Web Coding » JavaScript » onclick with animated gif


onclick with animated gif

Closed Thread
  #1 (permalink)  
Old 08-18-07, 10:13 PM
cedric813 cedric813 is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Hi everyone,

I have this piece of code on my page:

HTML Code:
<a href="www.something.com><img onclick="changeImg(this, 'pics/call_click.gif')" src="pics/call.gif" width="184" height="40" border=0 align="middle"></a>
When the image (call.gif) is clicked, it changes to another image (call_click.gif). This works perfectly until I put an animated gif in the second image (call_click.gif). Now, when I click the image it changes to the animted gif image but only displays the first frame of the animated gif and not the whole thing.

Does anyone know how I could fix this so that when the static image is clicked, the animated gif image starts playing?

Thanks so much in advance :-)

Sorry. I forgot to add the part that goes in the head:

HTML Code:
<head>
<script type="text/javascript">
function changeImg(img, newimg) {
img.src = newimg;
}
</script>
</head>
<body>
<a href="www.something.com><img onclick="changeImg(this, 'pics/call_click.gif')" src="pics/call.gif" width="184" height="40" border=0 align="middle"></a>
</body>

Last edited by Nico; 08-19-07 at 05:40 AM. Reason: Merged
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #2 (permalink)  
Old 08-20-07, 03:39 PM
jfulton's Avatar
jfulton jfulton is offline
Community VIP
 
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
First, try fixing your quotes.
HTML Code:
<a href="http://www.something.com"><img onclick="changeImg(this, 'pics/call_click.gif');" src="pics/call.gif" width="184" height="40" border="0" align="middle"></a>
If that doesn't work, can you link to an example? Also, what browser are you using?

(You know that since your image is inside of <a> tags, you need to prevent the browser from navigating to "http://www.something.com" right? Your code doesn't show that...)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #3 (permalink)  
Old 08-21-07, 03:39 AM
jfulton's Avatar
jfulton jfulton is offline
Community VIP
 
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
Hmmmm...didn't see your other thread. Please don't cross-post.

Closing thread...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GIF from GD? Zaiaku PHP 1 08-15-07 11:21 AM
Loading gif onmousedown Deansatch JavaScript 1 10-30-06 10:42 AM
how to use onclick in php coolcoder HTML/XHTML/XML 2 05-31-06 01:40 PM
Gif Pain mankopi HTML/XHTML/XML 3 09-12-05 07:53 PM
Firefox issue with animated gif mysticalmaze PHP 0 07-22-05 09:56 PM


All times are GMT -5. The time now is 01:15 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.