vchris Posted May 30, 2006 Share Posted May 30, 2006 Hey!Ok so I have a javascript that basically changes the image when the cursor is on it. Simple right? Well not for me it seems. Usually it is but it seems like it's not working today...First when I load the page the image is there and then on hover you only see the alt and the X in the corner. no pop-ups.Script <script type="text/javascript"> <!-- // //if browser is compatible if (document.images) { //preload images //base image a= new Image(91,40); a.src= 'topnav-home.jpg'; //hover or rollover image aover= new Image(91,40); aover.src= 'topnav-home-over.jpg'; function myOn(myImgName) { document[myImgName].src=eval(myImgName+ 'over').src; } function myOut(myImgName) { document[myImgName].src=eval(myImgName).src; } } //--> </script> HTML <li><a href="index.htm"><img src="images/topnav-home.jpg" name="a" height="40" width="91" alt="Home" onmouseover="myOn('a')" onmouseout="myOut('a')" /></a></li> For testing purposes I have changed the html name of the img to "a" to eliminate chances of typos. I have double and triple and quattriple checked the image file name and they are exact. I have copy pasted them to make sure.I have taken this code from 2 previous projects I've done and it worked perfectly.Thanks! Link to comment Share on other sites More sharing options...
scott100 Posted May 30, 2006 Share Posted May 30, 2006 Dude it works fine If i use two internet images then it works fine, you must be using incorrect file paths or something... <head><script type="text/javascript"><!-- // //if browser is compatibleif (document.images) { //preload images //base image a= new Image(91,40); a.src= 'http://www.google.co.uk/intl/en_uk/images/logo.gif'; //hover or rollover image aover= new Image(91,40); aover.src= 'http://us.i1.yimg.com/us.yimg.com/i/ww/beta/y3.gif'; function myOn(myImgName) { document[myImgName].src=eval(myImgName+ 'over').src; } function myOut(myImgName) { document[myImgName].src=eval(myImgName).src; } }//--></script></head><body><li><a href="index.htm"><img src="http://www.google.co.uk/intl/en_uk/images/logo.gif" name="a" height="40" width="91" alt="Home" onmouseover="myOn('a')" onmouseout="myOut('a')" /></a></li></body> Link to comment Share on other sites More sharing options...
Flic Posted May 30, 2006 Share Posted May 30, 2006 I have found before that images wouldn't show because the compression for the jpg was only at 1, might not be it but then might be something to check. Link to comment Share on other sites More sharing options...
vchris Posted May 31, 2006 Author Share Posted May 31, 2006 It must be somekind of bug with the page probably... I have checked so many times the paths and filenames, trust me it's fine. I guess I'll play around with my code and see. Link to comment Share on other sites More sharing options...
vchris Posted May 31, 2006 Author Share Posted May 31, 2006 I got it.... What a ###### error lol. I forgot you needed the "images/" path in there.I'll post my project in the show off the sites thread. It's very hot! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now