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!

onload -> does it wait for total document to load

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

I've been having a nightmare with GOAN no longer working propery, having posted on the google support site, its seems I'm not alone.

I thought to get round the problem of the JS error i'd wrap the body code in a function, put it in the head and use the onload to call the function.

this may be the wrong forum, so appologies, but my question is...

if you have a script which is linked to in the head, and then you use the onload to call a function in that script.

will the onload only fire if the entire document and the linked in scripts have fully loaded? i guess that includes CSS files also.

or does the external file load 'timeout' and the onload continues to fire regardless?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
will the onload only fire if the entire document and the linked in scripts have fully loaded?
Yes. That's exactly how it works using onload. You could consider looking at how some of the frameworks (specifically the latest (bleeding edge dev release) of Prototype (search in the code for "dom:loaded".

Cheers!
Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Yes. That's exactly how it works using onload

Then how on earth can the _gat not be defined if the external JS has loaded.

Is it something to do with the process ga.js script does and is it slower than the execution of the _gat.traker?

The initial thought that perhaps the external JS wasn't loading intime cannot be the case if browser waits for file to load.

But that throws another question in the air, if thats the case and you delete an attache JS file, the browser doesn't sit their churning waiting to load the script, it just ignores it an carries on, the same with CSS.

So the browser waits until everything loaded before fireing onload, cannot be an accrurate statement, there has to be more to it.

Is it relative to source status code? ie 404 = carry on, 200 = wait till loaded?

What about timeouts?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top