473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mouseover JS question

OK, I am new to Javascript but good with CSS and HTML coding. I have a little experience with Java and .NET as well. Here's what I'm trying to do.

I have three images of an animated spider. The first image is a simple gif with transparency (spider.gif - which is the state of the rollover when the page loads) and two other gif files. One is an animation of the spider turning counterclockwise (spider_f.gif) a bit, and the other is a reverse animation that returns it to the starting position(spider_r.gif).

I'm trying to get the code to activate on a mouseover and use a) spider.gif_f.gif if the image is in the start position or the spider_r.gif position. If moused over again it would then activate the spider_r.gif, and so forth.

The animation works fine on the first mouseover, but not on subsequent mouseover events. Here is what I have currently:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3.  
  4. <HTML>
  5.  
  6. <HEAD>
  7.  
  8. <TITLE>Test Title</TITLE>
  9.  
  10. <script language="javascript">
  11. <!--
  12.  
  13. function roll2(img_name2)
  14.    {
  15.     if (document[img_name2].src = "images/spider/spider_f.gif")
  16.     {document[img_name2].src = "images/spider/spider_r.gif";}
  17.  
  18.     else
  19.     {document[img_name2].src = "images/spider/spider_f.gif";}
  20.    }
  21.  
  22. //-->
  23. </script>
  24.  
  25.  
  26. </HEAD>
  27.  
  28. <BODY>
  29.  
  30. <IMG SRC="images/spider/spider.gif" width="90" height="104" border="0" 
  31. ALT="Jumping Spider" name="spider2" onmouseover="roll2('spider2')">
  32.  
  33.  
  34. </BODY>
  35.  
  36. </HTML> 
Any help would be greatly appreciated!
Thanks!!
Nov 17 '07 #1
1 1430
acoder
16,027 Expert Mod 8TB
On line 15, for comparison, you need to use == (double equals) as opposed to single equal.
Nov 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tyrone Slothrop | last post by:
I am coding a site which involves uploading images. All of the PHP and display is OK but the client wants to be able to display the image thumbnail on the upload page and show the full image on...
14
by: J. Makela | last post by:
Hallo. This should be a pretty entertaining question for you *real* javascript writers.. I, being the lowly photoshop guy at an ad agency made the mistake of actually saying "HTML" in a...
9
by: Kim | last post by:
Hi I'm trying to do something like this. for(i=0; i<5; i++){ var theData = document.createElement('a'); theData.onmouseover = function() { return get(i);} ... ... }
2
by: Alex | last post by:
On my page I have a lot string like this: <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc1</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc2</span> <span...
4
by: murrayatuptowngallery | last post by:
I have looked at some mouseover/ sound object scripts and can't get them to work. Most were more complex than needed and introduced several new parameters for me. I found a simple pair of html...
1
by: Steve Chatham | last post by:
I am moving some reports generated from a traditional ASP page to asp dotnet. In doing so, I have a listbox with x number of items in there. I've been asked to change the names somewhat to...
3
by: Annette Acquaire | last post by:
I have and image map with a dozen hotspot links on it that I'm trying to get to open a new image over existing one on mouseover of each COORD. The only thing I was able to do was swap image on...
1
sgeklor
by: sgeklor | last post by:
Dear All, My question refers to how best to organise my mouse events to correctly and efficiently give the effect I want. On my form I have a panel and that panel contains a number of controls....
7
by: Microsoft Newsserver | last post by:
Hi, Simple question, probably a simple answer hopefully. I am working with VS2005/2.0 and this is an Explorer project IE6/IE7. The issue is I need to be able to mouseover the options in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.