How do I excute later codes first?

N

none

some html here
<script src=1.js></script>
some html here
<script src=2.js></script>
some html here

I want to execute 2.js first, but I can not touch 1.js 2.js. I need to write
a wrapper around them. I am thinking to add a onload of a image file after
2.js to make 1.js active.

some html here
<script src=1.js></script>
some html here
<script src=2.js></script>
<img onload="to load 1.js">
some html here

How do I do this?
 
E

Evertjan.

none wrote on 05 nov 2004 in comp.lang.javascript:
some html here
<script src=1.js></script>
some html here
<script src=2.js></script>
some html here

I want to execute 2.js first, but I can not touch 1.js 2.js. I need to
write a wrapper around them. I am thinking to add a onload of a image
file after 2.js to make 1.js active.

some html here
<script src=1.js></script>
some html here
<script src=2.js></script>
<img onload="to load 1.js">
some html here

How do I do this?

the simple solution is:

some html here
<script src=2.js></script>
some html here
<script src=1.js></script>
some html here

but you could also wrap
the codes in functions to be executed later:

some html here
<script src=1.js></script>
some html here
<script src=2.js></script>
<img onload="funJS2();funJS1()">
some html here

However I cannot imagine what code needs to be handled this way.

Perhaps you were thinking of document.write(), but that function destroys
the page [your javascript included] if html is already outputted.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top