iframe内容访问javascript

时间:2014-02-19 18:55:44

标签: javascript iframe

在我的应用程序中使用以下代码创建弹出窗口并向其插入iframe。

     var win = window.open("", "", "height=200,width=150")        

    var newFrame = document.createElement("iframe");
    newFrame.setAttribute("src", "newpage.html");
    newFrame.setAttribute("name", "fr1");        

    win.document.body.appendChild(newFrame);

**var ifrm = win.document.getElementById('fr1');
ifrmdocument = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;**

我可以添加iframe但无法访问iframe文档。我的要求是我需要动态修改iframe内容。突出显示的行显示错误。

同时访问win.document.getElementById('fr1')时,我收到错误。 请分享您的想法。

0 个答案:

没有答案