兼容ff和ie
<iframe id="iframeContent" frameborder="0" scrolling="no" οnlοad="setHtmlContent();" src="页面地址"></iframe>
function setHtmlContent(isIE){
if(document.getElementById("iframeContent").readyState != 'complete' && isIE){
setTimeout("setHtmlContent();",30);
return ;
}
var frmContent = document.getElementById("iframeContent");
var frmBody = frmContent.contentWindow.document.body;
if(!frmBody) return;
if(frmBody.scrollHeight>frmContent.offsetHeight){
frmContent.height=frmBody.scrollHeight+"px";
}
if(frmBody.scrollWidth>frmContent.offsetWidth){
frmContent.style.width =(frmBody.scrollWidth+30).toString()+"px"
}
}
setHtmlContent(true);
<iframe id="iframeContent" frameborder="0" scrolling="no" οnlοad="setHtmlContent();" src="页面地址"></iframe>
function setHtmlContent(isIE){
if(document.getElementById("iframeContent").readyState != 'complete' && isIE){
setTimeout("setHtmlContent();",30);
return ;
}
var frmContent = document.getElementById("iframeContent");
var frmBody = frmContent.contentWindow.document.body;
if(!frmBody) return;
if(frmBody.scrollHeight>frmContent.offsetHeight){
frmContent.height=frmBody.scrollHeight+"px";
}
if(frmBody.scrollWidth>frmContent.offsetWidth){
frmContent.style.width =(frmBody.scrollWidth+30).toString()+"px"
}
}
setHtmlContent(true);