Simple onload for my js.file

N

Nody

I am trying figure out how to add body onload for external js file.
All the examples i found are more than i what i need.

Any help would be appreciated.
 
T

Tom de Neef

Nody said:
I am trying figure out how to add body onload for external js file.
All the examples i found are more than i what i need.

<HTML>
<HEAD>
...
<SCRIPT src="YourScriptFile.js" type="text/javascript"></SCRIPT>
</HEAD>
<BODY onload="initialize()"> // where function initialize() must be defined
in YourScriptFile
...
</BODY>
</HTML>

Tom
 
N

Nody

<HTML>
<HEAD>
...
<SCRIPT src="YourScriptFile.js" type="text/javascript"></SCRIPT>
</HEAD>
<BODYonload="initialize()"> // where function initialize() must be defined
in YourScriptFile
...
</BODY>
</HTML>

Tom

I cannot alter the java script. How can i get the page to load first
and then execute the script. Maybe some type of delay method.

Many Thanks
 
T

Thomas 'PointedEars' Lahn

Nody said:
Nody said:
I am trying figure out how to add bodyonloadfor external js file. All
the examples i found are more than i what i need.
<HTML> <HEAD> ... <SCRIPT src="YourScriptFile.js"
type="text/javascript"></SCRIPT> </HEAD> <BODYonload="initialize()"> //
where function initialize() must be defined in YourScriptFile ...
</BODY> </HTML>
[...]

Please don't quote signatures unless you explicitly refer to them.
I cannot alter the java script.

There is no "java script". Java != JavaScript.
How can i get the page to load first

There is no "page". There is an (X)HTML document instead.
and then execute the script.

If you mean executing the script code in the global execution context
without a method call: Reliably, you cannot.
Maybe some type of delay method.

Maybe not.


PointedEars
 
T

Tom de Neef

Nody said:
I cannot alter the java script. How can i get the page to load first
and then execute the script. Maybe some type of delay method.

I think that your js file will be loaded as part of the loading of the htm.
That may result in the initialization of global variables - I guess you can
not stop that.
You can change the onload call of <body> so that your own function is
executed rather than the original one. In that own function you would have
to mess around with a timer which calls the original function. But I do not
know enough about timers to judge if this can achieve your goal.
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,797
Messages
2,569,646
Members
45,374
Latest member
VernitaBer

Latest Threads

Top