UGN Security
Posted By: Moffesto preload images - 10/16/02 03:53 AM
Is there a html script or javascript that i could use to preload the images on a webpage?
Posted By: Energy Re: preload images - 10/16/02 10:22 AM
D you mean how do you specify the height and width of an image so the page, as it loads, knows how to place the text? If so the html syntax is:

<IMG SRC="/path/to/image" HEIGHT="48" WIDTH="48" ALT="My Image">

The 48 is in pixels.

A nice link is
http://www.devguru.com for many web coding questions.
Posted By: Moffesto Re: preload images - 10/17/02 01:45 AM
I mean... you know how the html loads first and then it takes time to load the pictures after... and for me (on a 24k connection) it takes forever to load the pictures. I'd like for the pictures to be preloaded so everythign loads at once, i know it will take just as long to load but id b a nice feature. if you know what i mean... im not a very good explainer.
Posted By: BackSlash Re: preload images - 10/17/02 06:26 AM
in javascript it is....

Code
<HEAD>

<SCRIPT language="JavaScript">

Image1= new Image(200,200)
Image1.src = "image.gif"

Image2= new Image(340,200)
Image2.src = "coolpic.jpg"

</SCRIPT>

</HEAD>

  
I think thats pretty much self explanitory. The variable name you use is irrelevant because you don't use that to call the image. You still put the image on your page like normal, this code just brings it into the cache before hand for a fast load. Think thats what you wanted.
Posted By: ReverendNinjaSox Re: preload images - 10/18/02 03:17 AM
I do mine in an extremely complex and dynamic manner. If you are doing yours dynamically as well. You may want to think about doing something like this.
Create a javascript function that looks similar to this.
Code
function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
That is my javascript function. Then I proceed to call it like this.

Code
<body onLoad="MM_preloadImages('image1.jpg','image2.jpg','image3.jpg');"
Doing this makes it really easy to dynamically specify all the images you are going to need.
Posted By: Moffesto Re: preload images - 10/21/02 02:42 AM
i dont know [censored] about javascript... i can just configure it alil but other than that... im lost. Do u put the first part in the head and the second in the body or what?
Posted By: ReverendNinjaSox Re: preload images - 10/21/02 11:44 AM
For mine? You'd just do what BackSlash did up there at first with the head and javascript tags. Then the body part would go with the body tag.
Posted By: BackSlash Re: preload images - 10/21/02 07:39 PM
mines easier :p
Posted By: ReverendNinjaSox Re: preload images - 10/22/02 04:18 PM
Not if you are making it dynamic! smile
Posted By: olosoft Re: preload images - 11/05/02 11:11 PM
uhh, yes, because you wrote that code yourself ReverendNinjaSox. its not at all the code that macromedia dreamweaver generates for you. MM_preloadImages. *sigh*
Posted By: ReverendNinjaSox Re: preload images - 11/06/02 06:38 PM
Oo. Good call. I didn't do the javascript. I do the perl that lies behind it.
© UGN Security Forum