Add to Window on Load

One of the things I would like to do with this blog is to share some of the code that I use on a daily basis. Over the last year I found that I was using the same functions over and over again. I was going through old code pulling out the functions I needed. This was time consuming because I didn't always remember where I used the code I needed.

I have started collecting code snippets to use and reuse in my projects, essentially creating my own code library. I recommend that any coder start this practice as it has saved me a lot of time.

So when I need to find a function, there it is.

I save each function or set of related functions together in a file that I save into a folder named after the language. So when I need to find a function, there it is.

I thought I would start off by sharing a most useful javascript function, Add to Window on Load. This function is useful on larger sites where you don't have access to add functions to the original window.onLoad().

That is it, pretty straight forward. I would like to point out that I did not write this code. Unfortunately I don't remember who wrote this, so if you know let me so they can get the credit they deserve. If you have any questions, let me know.

3 Comments »

  1. […] blog post: Add to Window on Load http://www.designbyblake.com/archives/49Posted 1 day […]

    Pingback by Design By Blake » Unobtrusive JavaScript is easy — June 3, 2008 @ 10:20 pm

  2. It’s by a gentleman called Simon Willison:

    http://simonwillison.net/2004/May/26/addLoadEvent/

    Comment by Paul — June 6, 2008 @ 4:21 am

  3. Good to know. Thank you Paul, and of course thanks to Simon Willison.

    Comment by Dan — June 14, 2008 @ 3:30 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment