Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you check if window is done loading?

Status
Not open for further replies.

conraba

MIS
Sep 27, 2002
17
0
0
US
Hi,

I have a a code in the parent window coded as such

var myWind=open(URL,'window' + i)

URL - is a link to an ftp site that contains ie. word or pdf file.

Thru a loop, I am openning a new window per document based on a link specified in the URL. Every window shows a new document.

Basically, I need to load each document one at a time. After a window opens and loaded a document, that's the only time it will open a new window for the next document.

How can I check if the window has fully loaded (downloaded and displayed a document) to be able to do a sequential loading.

Thanks for any help,
conraba
 
the event window.onload fires when the window has finished loading. you can attach code to this event.

<script>
function doneLoading() {
alert(&quot;done loading&quot;);
}
window.onload = doneLoading;
</script>

or

<script>
function doneLoading() {
alert(&quot;done loading&quot;);
}
</script>
<body onload=&quot;doneLoading();&quot;>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Jeff,

My fault, I should have explained more on what I was doing, its something like this.

URL - is an array containing &quot;links&quot; to a document
ex.
ftp://a-server/the_files/sample_notes1.doc
ftp://a-server/the_files/sample_notes2.doc
ftp://a-server/the_files/sample_notes3.doc


for(i=0; i < URL.length ; i++)
{
var myWind=open(URL(i),'window' + i)

//------------------------------
// Piece of code that checks if myWind is finished loading
//------------------------------
// while myWind has not loaded
// continue this loop or do a delay
}

when while...loop gets satisfied, thats the only time i'll open the next window with the next document.


Note:

I don't have access to the code on the new windows, so I can't do a check on the onload events.

Thanks again for any inputs,
conraba
 
in IE only, you can check document.readyState - it will be &quot;complete&quot; when loaded. however, if the urls are in a different domain, you probably won't have access via javascript for security reasons

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top