javascript dynamically add frame to frameset

大兔子大兔子 提交于 2019-12-25 04:38:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!