473,394 Members | 1,773 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,394 software developers and data experts.

image mouseover problem

Hi.
A friend of mine asked me if I could look at one of his java scripts in order to get it working. Unfortunately I am stumped and was wondeirng if somebody with a bit more experience than myself can look it over and help me identify what is wrong .

Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. <!-- Begin
  3. image10 = new Image();
  4.  
  5. var imageDir = "http://2005.rock103.com/pages/bod/thong/";
  6. var d = new Date()
  7. var month = (String(d.getMonth() + 1))
  8. var day = (String(d.getDate()))
  9. var year = (String(d.getYear()))
  10. var imagename 
  11.  
  12. if(d.getMonth() < 10)
  13. imagename = ("0"+ month)
  14. else
  15. imagename = month
  16.  
  17. if(d.getDate() < 10)
  18. imagename = imagename + ("0" + day)
  19. else
  20. imagename = imagename + day
  21.  
  22. imagename = imagename + year.substr(2)
  23.  
  24. image10.src = imageDir + imagename + '.jpg';
  25.  
  26. document.write ('<TD align="center">')
  27. document.write ('<font size="2" face="Verdana" color="FFFFFF">')
  28. document.write ('<b>BONUS BABE</b>')
  29. document.write ('</font>')
  30. document.write ('<a href="' + imageDir + imagename + '.jpg" target="topstart" ')
  31. document.write ('onmouseover="image10.src=' + imageDir + imagename + '.jpg;" ')
  32. document.write ('onmouseout="image10.src=http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif;">')
  33. document.write ('<img name="image10" src="http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif" border=0 width=136 height=140></a>')
  34. document.write ('</TD>')
  35. // End -->
  36. </script>
  37.  
  38.  
The mouseover does not appear to be working. The gif appears and if I click on it (the gif) I can get a new window to open and the image will load. However, the mouseover does not work. Can anybody help me? Thanks in advance.
Jul 12 '07 #1
4 1762
Logician
210 100+
The mouseover does not appear to be working. The gif appears and if I click on it (the gif) I can get a new window to open and the image will load. However, the mouseover does not work. Can anybody help me? Thanks in advance.
Try changing
Expand|Select|Wrap|Line Numbers
  1. image10.src=
to
Expand|Select|Wrap|Line Numbers
  1. document.images.image10.src=
If it still doesn't work, post any error messages from the console.
Jul 12 '07 #2
Try changing
Expand|Select|Wrap|Line Numbers
  1. image10.src=
to
Expand|Select|Wrap|Line Numbers
  1. document.images.image10.src=
If it still doesn't work, post any error messages from the console.
Following is the original code before making changes ...

Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. <!-- Begin
  3. image10 = new Image();
  4.  
  5. var imageDir = "http://2005.rock103.com/pages/bod/thong/";
  6. var d = new Date()
  7. var month = (String(d.getMonth() + 1))
  8. var day = (String(d.getDate()))
  9. var year = (String(d.getYear()))
  10. var imagename 
  11.  
  12. if(d.getMonth() < 10)
  13. imagename = ("0"+ month)
  14. else
  15. imagename = month
  16.  
  17. if(d.getDate() < 10)
  18. imagename = imagename + ("0" + day)
  19. else
  20. imagename = imagename + day
  21.  
  22. imagename = imagename + year.substr(2)
  23.  
  24. image10.src = imageDir + imagename + '.jpg';
  25.  
  26. document.write ('<TD align="center">')
  27. document.write ('<font size="2" face="Verdana" color="FFFFFF">')
  28. document.write ('<b>BONUS BABE</b>')
  29. document.write ('</font>')
  30. document.write ('<a href="' + imageDir + imagename + '.jpg" target="topstart" ')
  31. document.write ('onmouseover="image10.src=' + imageDir + imagename + '.jpg;" ')
  32. document.write ('onmouseout="image10.src=http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif;">')
  33. document.write ('<img name="image10" src="http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif" border=0 width=136 height=140></a>')
  34. document.write ('</TD>')
  35. // End -->
  36. </script>
  37.  
IE Script Debugging Output showed:

Line:36
Char: 17
Error: Expected ';'
Code: 0

I made the following changes ...

Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. <!-- Begin
  3. image10 = new Image();
  4.  
  5. var imageDir = "http://2005.rock103.com/pages/bod/thong/";
  6. var d = new Date()
  7. var month = (String(d.getMonth() + 1))
  8. var day = (String(d.getDate()))
  9. var year = (String(d.getYear()))
  10. var imagename 
  11.  
  12. if(d.getMonth() < 10)
  13. imagename = ("0"+ month)
  14. else
  15. imagename = month
  16.  
  17. if(d.getDate() < 10)
  18. imagename = imagename + ("0" + day)
  19. else
  20. imagename = imagename + day
  21.  
  22. imagename = imagename + year.substr(2)
  23.  
  24. image10.src = imageDir + imagename + '.jpg';
  25.  
  26. document.write ('<TD align="center">')
  27. document.write ('<font size="2" face="Verdana" color="FFFFFF">')
  28. document.write ('<b>BONUS BABE</b>')
  29. document.write ('</font>')
  30. document.write ('<a href="' + imageDir + imagename + '.jpg" target="topstart" ')
  31. document.write ('onmouseover=" document.images.image10.src  =' + imageDir + imagename + '.jpg;" ')
  32. document.write ('onmouseout="document.images.image10.src  ==http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif;">')
  33. document.write ('<img name="image10" src="http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif" border=0 width=136 height=140></a>')
  34. document.write ('</TD>')
  35. // End -->
  36. </script>
  37.  
IE Script Debugging Output now shows:

Line:36
Char: 33
Error: Expected ';'
Code: 0
Jul 13 '07 #3
Logician
210 100+
It's better to develop with Mozilla as its error messages are more useful.
There were missing quotes around the src parameters in the document.write statement. I added an alert to show the generated image path.
Expand|Select|Wrap|Line Numbers
  1. <script type="text/JavaScript">
  2.  
  3. image10 = new Image();
  4.  
  5. var imageDir = "http://2005.rock103.com/pages/bod/thong/";
  6. var d = new Date();
  7. var month = (String(d.getMonth() + 1));
  8. var day = (String(d.getDate()));
  9. var year = (String(d.getYear()));
  10. var imagename;
  11.  
  12. if(d.getMonth() < 10)
  13. imagename = ("0"+ month);
  14. else
  15. imagename = month;
  16.  
  17. if(d.getDate() < 10)
  18. imagename = imagename + ("0" + day);
  19. else
  20. imagename = imagename + day;
  21.  
  22. imagename = imagename + year.substr(2);
  23.  
  24. alert( image10.src = imageDir + imagename + '.jpg' );
  25.  
  26. document.write ('<TD align="center">');
  27. document.write ('<font size="2" face="Verdana" color="FFFFFF">');
  28. document.write ('<b>BONUS BABE</b>');
  29. document.write ('</font>');
  30. document.write ('<a href="' + imageDir + imagename + '.jpg" target="topstart" ');
  31. document.write ('onmouseover="document.images.image10.src=\'' + imageDir + imagename + '\'.jpg;" ');
  32. document.write ('onmouseout="document.images.image10.src=\'http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif;\'">');
  33. document.write ('<img name="image10" src="http://www2.bc.edu/~olivieri/animated_gifs/football_spinning.gif" border=0 width=136 height=140></a>');
  34. document.write ('</TD>');
  35.  
  36. </script>
Jul 14 '07 #4
acoder
16,027 Expert Mod 8TB
Changed thread title.
Jul 14 '07 #5

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

Similar topics

4
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what...
5
by: Jim Buzbee | last post by:
I have a subroutine that inserts image objects into a page for me. It works fine except for one thing. My mouseover settings don't appear to take. i.e. I see nothing at all when I move the mouse...
3
by: John | last post by:
Imagine this: I have a gif-image with text, coloured green. When MouseOver occurs the gif will swap to another gif with red colourded text. On MouseOut the gif turns back to the green text. ...
0
by: Victor Bastiaansen | last post by:
For use in a menu I build a stylesheet which crops an image which contains both the normal button-state and the mouseover-state. On a mouseover the layer background-images 'moves', and another part...
2
by: Jeronimo Bertran | last post by:
I have an aspx page that shows a complex image with several objects that are sensitive to mouseover events. The information about the objects in the image is obtained from a database and complex...
2
by: Amy | last post by:
<style> div.helpBtn{ font:bold 73% verdana; color:#995F8D; text-align:left; width:79px; height:24px; margin:0px; padding: 5px 0px 0px 27px; background:...
3
by: lofty00 | last post by:
hello, sorry about the repost - I've been posting to several groups and I've decided it's better to make a single repost to all of them rather than an extra post in each. I've been trying to...
3
by: seamlyne | last post by:
The first method I ever used for multiple state buttons was to create a graphic for each button for each state: AboutUs_on, AbooutUs_over, AboutUs_out, etc. That works great when there are just a...
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...
13
by: seegoon | last post by:
Hi all. So: I've put together a page, in which I want several clickable image maps. I've put those together already. The problem with image maps is that they're not very intuitive, so users don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.