我正在尝试访问以下代码中iframe的contentDocument和contentWindow。但它们都是null。
var iframe = document.createElement('iframe');
this.get__domElement$i().appendChild(iframe);
if (iframe.contentDocument) {
iframe.contentDocument.write("Hello");
}
else if (iframe.contentWindow) {
iframe.contentWindow.document.body.innerHTML = "Hello";
}
有人能告诉我这个代码哪里出了问题吗?谢谢。
当我使用Document.Body.AppendChild(iframe)时,contentDocument和contentWindow是非空的。
有人能告诉我将iframe附加到div时可能出现什么问题吗?
非常感谢。