PDA

View Full Version : Preloading images



Johank82
11-25-2005, 05:09 PM
When I am moving my mouse over links in the menu at http://nintendosan.atspace.com it takes some time for the pictures to load. This is the script I use between the head tag, but it doesn´t work. Why?

<SCRIPT language="JavaScript">
<!--
pic1= new Image(245,153);
pic1.src="test.jpg";

pic2= new Image(245,153);
pic2.src="test2.jpg";

pic3= new Image(245,153);
pic3.src="test3.jpg";

pic4= new Image(245,153);
pic4.src="test4.jpg";
//-->
</SCRIPT>

Twey
11-25-2005, 05:30 PM
Preloading images doesn't magically make them download instantly - it merely loads them before everything else, used properly. However, your code will not wait until the images are loaded before loading the rest of the page. The images are loading at the same time as the page.

Johank82
11-25-2005, 08:21 PM
Is it possible to make the pictures appear instantly in explorer? In mozilla they do, but not in explorer

Twey
11-25-2005, 08:51 PM
Of course it isn't. They have to be downloaded at some point, which means they're limited by the speed of the connection.