New
#1
Javascript image problem
Hello colleagues,
I was trying to make an onMouseOver effect with one image with Javascript. It works perfectly fine, the only issue was, that when I mouse over the image, it generates the other one very slowly. So I decided to preload the images before using them and that way it is will be much faster. The only problem is that it doesn't work and I have no idea why . I mean the onmouse effect works, but the speed of loading the image is the same even without the preloading code. Can you please help me? Here is the JS code:
And the HTML code of the image I want to format:Code:if(document.image){ var pic1 = new Image(); pic1.src = "http://farm6.static.flickr.com/5135/5515445106_d27e289646_m.jpg"; var pic2 = new Image(); pic2.src ="dimitar_shumen.jpg"; } function mouse_over(){ document.getElementById("pic1").src = "dimitar_shumen.jpg"; } function mouse_out(){ document.getElementById("pic1").src ="http://farm6.static.flickr.com/5135/5515445106_d27e289646_m.jpg"; }
Code:<a href="http://www.flickr.com/photos/59988828@N03/5515445106/" title="dimitar_shumen by ChessAdmin, on Flickr"><img src="http://farm6.static.flickr.com/5135/5515445106_d27e289646_m.jpg" alt="dimitar_shumen" id="pic1" onmouseover="mouse_over()" onmouseout="mouse_out()"/></a>
If you need, I will also provide the code of the entire page, if necessary.
Thank you in advance!
Best Regards
Stefany