What is the best way to handle multiple onload loading scripts on different pages?
For example, I have 50 different pages, and on each page I want to set a different button click handler when dom is ready.
Is it better to install onclicks as on every single page,
<a id="link1" href="#" onclick="myFunc()" />
Or a very long documentation in an external js file,
Element.observe (window, 'load', function () {
if ($ ('link1')) {
// set click handler
}
if ($ ('link2')) {
// set click hanlder
}
...
}
Or separate each section if ($('link')) {}
into script tags and place them on the appropriate pages,
, , if ($('link')) {}
js ?
1 , 2 , 3 , 1, , 4 , js , .
- ( ) 5, ?
: , , onload .