innerHTML and images loading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nick

    innerHTML and images loading

    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
  • Ivo

    #2
    Re: innerHTML and images loading

    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.g if"; ge.scr="That.jp g";

    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<argum ents.length;i++ ){
    x=new Image();x.src=a rguments[i];
    }
    }
    preload("This.g if","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

    nikolajs1968@ya hoo.com (nick) wrote in message news:<83e25c9a. 0309200639.19de 79fc@posting.go ogle.com>...[color=blue]
    > 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
    > 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[/color]

    Comment

    Working...