innerHTML and images loading

N

nick

Dear All,

I have a little strange problem with using innerHTML property to
update my browser document.
The HTML content I am inserting in document contains images. These
images are to be downloaded from the web.
Well, they are downloaded and everything works, BUT:

on relatively small network, I can see how these images are loaded one
by one, as if requests for these images were sent sequentuially. This
does not happens if I get the same content in "common" way (not using
innerHTML).

Have anybody seen this effect ?

I had a kind of hypothesis about it. Maybe setting innerHTML through
javascript (which is what I am doing) works in a signle thread, and
this is a reason why requests are sent sequnetially ?

Thanks & Regards,

Nick
 
I

Ivo

Not sure what the problem is. Do you want all images to be there at
the same time? Preload them. That is: tell the browser you are going
to need image This and image That, and it will download and cache
them, so that they are instantly displayed the moment you set your
innerHTML.

You tell the browser to cache an image with something like:
var ima= new Image(); var ge=new Image();
ima.src="This.gif"; ge.scr="That.jpg";

or a function that takes an arbitrary number of files (you can also
preload css and script files or other pages) as its arguments:
function preload(n){
for(i=0;i<arguments.length;i++){
x=new Image();x.src=arguments;
}
}
preload("This.gif","That.jpg");

If something else is the problem, disregard this post.:)
I believe every browser has an x number of ports or threads to
download a page and its associate files. The more pages I request at
once, the more apparent the sequential loading is.
HTH
Ivo
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top