问题
The following favelet in IE is causing something similar to a document.write which is displaying [object]?
I am attempting to dynamically add a frame to get javascript variables from another page to autopopulate a form. I cannot edit the source this must execute from a favorite or bookmark.
javascript:
var newFrame = document.createElement("frame");
newFrame.id = "externalFrame";
newFrame.name = "externalFrame";
newFrame.src = "listparent.jsp?listType=all";
var m = document.getElementById('mainframeset');
m.appendChild(newFrame);
The html page looks like this
<html>
<frameset id=mainframeset cols="*,0">
<frame src="issue.jsp" name="editor">
<frame src="adminPoller.jsp" name="poller" scrolling=no>
</frameset>
</html>
Thank you!
回答1:
I finally ended up solving my problem by adding an element to a frame document instead of the mainframeset.
var body = window.frames['editor'].document.getElementsByTagName("body")[0];
var elem = window.frames['editor'].document.createElement("iframe");
body.appendChild(elem);
来源:https://stackoverflow.com/questions/1353215/javascript-dynamically-add-frame-to-frameset