6
我想在下面的代碼中訪問iframe的contentDocument和contentWindow。但他們都是空的。iframe contentDocument和contentWindow爲空
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?
非常感謝。