You might call us slackers, or you might base it on our faulty understanding of the defer attribute (and this site will confirm it), but we thought that adding the defer attribute to our inline code thus;
Would mean that the inline script wouldn't be executed until the whole page is loaded. So you could effectively add the code anywhere in the page - say, the header - and it didn't matter. Well, what works in Internet Explorer doesn't always work in Firefox (et al.).
The code itself is running a getElementByID() call, so the element it's looking for needs to exist on the page for the script to function properly. If the function call is made when the entire page is loaded, then the element you're targeting will exist, and obviously if you're calling the function inline - before the appropriate section of the page has been rendered - then the element won't exist. Think the defer attribute would solve it? Alas, you are wrong.