1
我動態創建一個iframe:如何關閉使用JavaScript滾動的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滾動?