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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

body.onload from external script?

Status
Not open for further replies.

pbb72

Programmer
Mar 27, 2004
38
NO
I need a way to auto-execute a script function after loading and after resizing of a page. This script is located in an external JavaScript file, and the event handlers have to be defined in the script file (the document itself can't have an onload attribute or script calls). The auto-loading function needs to be executed after the page has been built, since I need access to the clientHeight property...

Can anybody please help me?
 
sure - suppose you want to trigger a function foo() when the page loads, then:

window.onload = foo;



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
aaaaargh.... how stupid could i have been! i've kept on trying to use document.body.onload, which didn't work because the body object hadn't been created yet. i've been looking for an answer in the wrong place again... thanks a million !!
 
note however that this will overwrite anything previously assigned to window.onload



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
I understand... Best to check the existing value of window.onload and execute that also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top