www.webdeveloper.com
Results 1 to 3 of 3

Thread: JS n00b preload images problem

  1. #1
    Join Date
    Oct 2005
    Location
    UK
    Posts
    630

    Question JS n00b preload images problem

    I have this Javscript that im using to preload images that rollover but for some reason it seems to do nothing. It would help if it errored :S
    Code:
    <script type="text/javascript">
    		<!--
    			if (document.images)
    				{
    					preload_image_object = new Image();
    					// set image url
    					image_url = new Array();
    					image_url[0] = "images/image_1_rollover.jpg";
    					image_url[1] = "images/image_2_rollover.jpg";
    					image_url[2] = "images/image_3_rollover.jpg";
    					image_url[3] = "images/image_4_rollover.jpg";
    					image_url[4] = "images/image_5_rollover.jpg";
    					image_url[5] = "images/image_6_rollover.jpg";
    					image_url[6] = "images/image_7_rollover.jpg";
    					image_url[7] = "images/image_8_rollover.jpg";
    					image_url[8] = "images/image_9_rollover.jpg";
    					image_url[9] = "images/image_10_rollover.jpg";
    					image_url[10] = "images/enterflashsiterollover.png";
    					image_url[11] = "images/enterhtmlsiterollover.png";
    					
    					var i = 0;
    					for(i=0; i<=9; i++){preload_image_object.src = image_url[i];}
    					}
    		//-->
    		</script>

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,689
    Code:
    <script type="text/javascript">
    		<!--
    			if (document.images)
    				{
    					preload_image_object =[];
    					// set image url
    					image_url = new Array();
    					image_url[0] = "images/image_1_rollover.jpg";
    					image_url[1] = "images/image_2_rollover.jpg";
    					image_url[2] = "images/image_3_rollover.jpg";
    					image_url[3] = "images/image_4_rollover.jpg";
    					image_url[4] = "images/image_5_rollover.jpg";
    					image_url[5] = "images/image_6_rollover.jpg";
    					image_url[6] = "images/image_7_rollover.jpg";
    					image_url[7] = "images/image_8_rollover.jpg";
    					image_url[8] = "images/image_9_rollover.jpg";
    					image_url[9] = "images/image_10_rollover.jpg";
    					image_url[10] = "images/enterflashsiterollover.png";
    					image_url[11] = "images/enterhtmlsiterollover.png";
    
    					var i = 0;
    					for(i=0; i<=9; i++){
                         preload_image_object[i]=new Image();
                         preload_image_object[i].src = image_url[i];}
                       	}
    		//-->
    		</script>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Oct 2005
    Location
    UK
    Posts
    630
    cheers much appreciated

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles