exteding onload event

A

Andrew Poulos

I have an external js file where I set an onload event:

window.onload = function() {
//blah
}

I import the file in the head of the pages I'm working on. Some of the
pages need unique things set onload (including those in the external
js). How can I extend the window.onload in the external js to include
things unique to each page?


Andrew Poulos
 
E

Evertjan.

Andrew Poulos wrote on 24 mrt 2005 in comp.lang.javascript:
I have an external js file where I set an onload event:

window.onload = function() {
//blah
}

I import the file in the head of the pages I'm working on. Some of the
pages need unique things set onload (including those in the external
js). How can I extend the window.onload in the external js to include
things unique to each page?

<script type='text/javscript'>
var page=1
</script>
<script type='text/javscript'
src='myScript.js'>
</script>

===========================

in myScript.js:

window.onload = function() {
if (page==1) {..set this..}
if (page==2) {..set that..}
}
 

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,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top