Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old February 10th, 2006, 04:45 AM
stahl.karl@gmail.com
Guest
 
Posts: n/a
Default Update image immediately? How to avoid waiting until onload() finishes?

I am trying to update an image when I load a page, then perform a bunch
of other actions that take a while. The problem is that the image does
not update until the entire function has finished running. Is there
some command that will allow me to force the first line to run, THEN do
the rest of the other stuff in the function? Here's an example of what
I am trying to do:

<script type=text/javascript>

function do_stuff_on_load {

mycell.innerHTML="<img src=" + image + ">"

...do a bunch of other stuff that takes a long time

}
</script>

<body onload=do_stuff_on_load()>
<table>
<tr>
<td id=mycell>
</body>


Thanks so much!




  #2  
Old February 10th, 2006, 07:45 AM
alexey@shtokalo.net
Guest
 
Posts: n/a
Default Re: Update image immediately? How to avoid waiting until onload() finishes?

I think you can try to use setTimeout() function with small timeout
value to start image loading...

setTimeout('mycell.innerHTML="<img src="' + image + '">"', 200);

or split the onload action into fast and slow parts...

function do_stuff_on_load {

mycell.innerHTML="<img src=" + image + ">"

setTimeout('do_stuff_on_load_continue()', 200);

}

function do_stuff_on_load_continue {

...do a bunch of other stuff that takes a long time

}

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.