I posted a new article to PengoWorks.com today that shows a technique for running multiple onload events without altering your base source code. Here's a quote:
One of the most common things I run into while developing sites dependant on JavaScript is the need to have multiple operations run during <body>'s onload event. I think this is a problem most developers run into, since it's very common to develop a set of "shared border" templates that render the shell of your site and the body of your document is included via a server-side command.
Often you have the need to invoke some JavaScript during the onload event of every page. This might be to render a DHTML-based menu, or simply to initial some information about the page, regardless, you need this information to run on every page.
However, you often run into the case were you need to run some addition commands based upon the page that's being inserted. Most often this happens when I'm developing a page that has a form on it. There are a lot of ways to tackle this problem, but the tip I'm going to share with you is the one that I've found over the years to be the best solution. For a lack of a better term, I'll call this the "Auto-init()" method.
If you have any comments about the article, please post a comment!
2 Comments
Comments for this entry have been disabled.