473,808 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image mouseover problem

2 New Member
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 1783
Logician
210 New Member
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
ericjiii
2 New Member
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 New Member
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 Recognized Expert Moderator MVP
Changed thread title.
Jul 14 '07 #5

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

Similar topics

4
16219
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 I've come up with. In this example, there are 5 images (0 thru 4) all with a height of 80px. When you mouse over an image, it changes the growingImage variable equal to the number of the image you mouse over, when you mouse out, it sets it to 5,...
5
1803
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 cursor over the image. If I replace the object creation code with a plain document.write, it works. : // this works as expected document.write("<img src='marker12.gif' \ id='1' \
3
13459
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. -----------------This is my code: <a href="nextpage.html" onMouseOver="document.green.src='red.gif'" onMouseOut="document.green.src='green.gif'">
0
1777
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 of the image will be visible (to be clear: the mouseover-image is allready loaded). This all works fine, but a problems seems to occure when the browser-cache is getting full. on a mouseover the movement of the layerbackgroundimage is somewhat...
2
1442
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 calculations are performed for each object to determine the position within the image. To render the image I created an aspx page that uses the following code to render the image: Response.ContentType = "image/jpeg";...
2
4027
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: url(/jsp/images/pms/housekeeping/helpBtn_off.gif) no-repeat; } div.helpBtnOn{ font:bold 73% verdana; color:#BB59DE; text-align:left; width:79px; height:24px; margin:0px; padding: 5px 0px 0px 27px; background: url(/jsp/images/pms/housekeeping/helpBtn_on.gif) no-repeat; cursor:pointer; }...
3
3325
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 work out why I can't get the image maps to work in IE6 on a page I'm working on (which is now working in firefox). I've written the page below as a test case. It's now refusing to work in Firefox either, and I can't see anything wrong with it so...
3
5673
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 few buttons. I'm creating interfaces now with many more buttons than "just a few". I solved the maintenance problem by having generic button images, one for each state, and having them be background images for text containers, DIVs in this...
3
19502
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 mouseover entire image, I want it on each hotspot only, so an image pertaining to each link shows up. I have done it in JavaScript, but the website I'm using doesn't use JavaScript. Y'all are obviously light-years more knowledgeable then me on html...
13
5364
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 really expect the image to be clickable and accordingly won't even try to. The solution is to have the image highlight whenever the mouse travels over the mapped-out area; I understand that this is quite easy. Some Googling has provided a few...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10628
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10373
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9195
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5547
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.