我正在动态创建一个 iframe:
function iFrame(parentElement)
{
var iframe = document.createElement("iframe");
if (parentElement == null)
{
parentElement = document.body;
}
parentElement.appendChild(iframe);
iframe.doc = null;
if (iframe.contentDocument)
{
iframe.doc = iframe.contentDocument; // Opera, Firefox
}
else if(iframe.contentWindow)
{
iframe.doc = iframe.contentWindow.document; // Internet Explorer
}
else if(iframe.document)
{
iframe.doc = iframe.document;
}
if(iframe.doc == null)
{
throw "Application failed to dynamically create an iframe content";
}
iframe.doc.open();
iframe.doc.close();
return iframe;
}
...与 document.onload:
function onPageLoad()
{
var iframeDiv = document.getElementById("iframeDiv");
var iframe = new iFrame(iframeDiv);
}
如何将此 iframe 拉伸到其父 div 并使用 JavaScript 关闭滚动?