You can access a frame or iframe using the following syntax
You can easily add elements to the frames DOM using the frame reference above:
var frame = window.frames["name_of_frame"];
Note above that the node was created using the frame reference, since you can not append a node that was created in one document to another document.
var p = frame.document.createElement("p");
p.innerHTML = "tada!";
Firefox will throw the following error if you omit the bold part above:
One last thing, you need to make sure that the frame content is loaded before you start adding elements to it.
Error: uncaught exception: [Exception... "Node cannot be used in a document other than the one in which it was created" code: "4" nsresult: "0x80530004 (NS_ERROR_DOM_WRONG_DOCUMENT_ERR)"]