penders - 5:36 pm on Dec 28, 2011 (gmt 0)
I think the document is already complete by the time you attempt to document.write(), hence why it fails. The onload event fires after everything has finished loading, including all your images etc. This is a long time after the DOM itself is complete.
If this was to work, where in the document do you envisage the text being written?
How are you attempting to write it to an iframe?
I think you will need to write to the DOM using the conventional methods you mention. You do not necessarily need a specific id or class in which to target the element. Providing you can reliably traverse the DOM to get to the required element then you can write to it.