<!– Some HTML goodness…–>
As you can see from the example above, we are using an HTML attribute (in this case onload) to run a function. So someFunction() will run when the page loads. There are a lot of events…
// Attach a function to the onload event window.onload = someFunction();
So we can ‘wire up’ our HTML events without even going into the HTML! You can do this for all the events. Frameworks, such as jQuery make this stuff even easier and less verbose. I will save those topics for when I cover some jQuery stuff though.
Now, there is an issue with the way I did it. We cannot pass arguments this way. This is where function literals come into play. I will save that topic for a future post..coming soon. How’s that for a teaser?