Over a million developers have joined DZone.

Using Event.observe For When A Page Loads

DZone's Guide to

Using Event.observe For When A Page Loads

Free Resource
I just prefer this implementation as opposed to window.onload.

Event.observe( window, 'load', function() {
  // Put the Javascript that needs to happen when the page
  // loads here
} );

For example, here's a way to make most of your input fields and all of your textareas have a different class when they're selected.  Useful if you want to style them differently with CSS.
Event.observe( window, 'load', function() {
  var inputs = document.getElementsByTagName( 'input' );
  var textareas = document.getElementsByTagName( 'textarea' );

  for ( var i=0; i

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}