Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Preloading images - code


<head>

<script language="javascript">

function preloadImage(){

var pic //Holds the image object
var pic = new Image()//Create an image object /*
Set the image object's src property to an existing image
*/
pic.src = "images/pl1.jpg"
if(pic.complete){//Has this image been previously loaded?
/*
Call the redirect function immediately since the image was loaded before
*/
redirect()
}else{//The image has changed or it was never loaded
/*
Make the onLoad event of the image call the redirect function as soon as
all image data for the image is received
*/
pic.onload = redirect
}
function redirect(){//Define the redirect function
/*
Change the URL of the current window to a new file.
This file contains an image tag that holds the loaded image
*/
window.location="image_preload_win.htm"
}
}
</script>
</head>

<!--

Define the button in a form
--> <body><!-- Open the body tag -->
<form><!-- Open the form -->
<!--
Make the button and make it call the preloadImage function
when the user clicks on it.
This allows the user to start the process
-->
<input type="button" value="Prepare web application" onClick="preloadImage">
</form><!-- Close the form -->
</body><!-- Close the body element -->


Close