There’s not a single serious web site I did, where I haven’t combined two or more scripts. Calendars, DHTML layers, cookies…they all have one thing in common - they want to grab window.onload for them self.
I usually dealt with that by changing the onload function for last loaded script. This was a pain when for some reason I needed to change the loading order.
When I got tired of it, I wrote a custom script, that’s loaded before all others, and gathers all of them into one piece.
Internet Explorer 5 and later have attachEvent method for all objects, but I wanted a script to work in all browsers. First version I wrote was dealing with just non-IE5+ browser - I used existing method for IE5+. After first real use, I realized that IE5 does not execute functions in the exact order they were added, so I removed browser-detection (an added benefit) and used this script for all.
Include this script file first, and then add other scripts' onload functions like this:
function_name should not include brackets (and thus no arguments can be passed). I wrote this script long time ago, so I don’t remember exactly why is this necessary (I think that eval call went crazy with it).
Scripts also supports onresize, and no other events, and it works only with window object. If you need other events, just add corresponding
AE_Window_Event_() function, similar to existing
If you need this for objects other than window, write the functions from above, and add needed line(s) of code to
Or you can completely extend the script to work with any object, any event. Your call; this worked for me.