Preload image

V

Victor

Hi guy.
My website is a image heavy website.. some of are using background. There
background always be loaded at the last.
is there anyway I can load these image at the begining of the page be
loaded. so that they can come out at the same time as other images


cheers
Victor
 
M

Mike Placentra II

Well, it's common to preload images using JavaScript for rollover
buttons and such, but I'm not sure if that could be used to change the
priority of image loading. You can give it a shot, though. Here's code
that would otherwise be used to do it:

function preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.p) d.p=new Array();
var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a.indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a;}}
}

You'd pass as many urls to images to that as needed. This is a
function that Macromedia Dreamweaver 2004 would throw in the head and
then it would be called in the OnLoad handler of the body element. You
can try to call it some other way to get it run sooner, though.

-Michael Placentra II
 
S

Steven Cheng[MSFT]

Thanks for Mike's input.

Hi Victor,

Here is a web article give some advice about preload image through CSS:

#Preloading Images With CSS
http://www.netmechanic.com/news/vol6/css_no18.htm

Also, mostly such image or other page stuff loading is mostly depend on the
client webbrowser.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: Mike Placentra II <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Re: Preload image
Date: Tue, 02 Oct 2007 01:14:17 -0000
Well, it's common to preload images using JavaScript for rollover
buttons and such, but I'm not sure if that could be used to change the
priority of image loading. You can give it a shot, though. Here's code
that would otherwise be used to do it:

function preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.p) d.p=new Array();
var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a.indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a;}}
}

You'd pass as many urls to images to that as needed. This is a
function that Macromedia Dreamweaver 2004 would throw in the head and
then it would be called in the OnLoad handler of the body element. You
can try to call it some other way to get it run sooner, though.

-Michael Placentra II


Hi guy.
My website is a image heavy website.. some of are using background. There
background always be loaded at the last.
is there anyway I can load these image at the begining of the page be
loaded. so that they can come out at the same time as other images

cheers
Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top