See the attached test case (which works as expected in Firefox and WinIE).
The document body has an element:
For whatever reason, document.getElementById("console") returns null if called from an IFrame onload handler.
Created attachment 6367 [details]
Starts to work if the iframe is moved below <p>.
"onclick handler" in the alert was supposed to be "onload handler", of course. It is there to indicate that the handler is called at all (didn't fire before, bug 3609).