在网上找了很多,都不行,晕阿,今天偶尔改了下代码,可以了,哈哈
网上找到的代码如下:
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0
function isiFrameLoadComplete(iframename){
var pTar = document.getElementById(iframename);
if(pTar.readyState=="complete"){
return true;
}else{
return false;
}
}
function dsed_resize(iframename) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(iframename);
}
else{
eval(''''pTar = ''''+iframename+'''';'''');
}
pTar.height = 25;
if (pTar && !window.opera){
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
if(pTar.height<=25){
pTar.height = 25;
}else if(pTar.height>=210){
pTar.height = 210;
}
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
if(pTar.height<=25){
pTar.height = 25;
}else if(pTar.height>=210){
pTar.height = 210;
}
}
}
}
总是出错,后来将 pTar.height 改为 pTar.style.height 就 OK了
资源:
关于IFRAME 自适应高度的研究
http://www.cnsdn.com.cn/blog/article.asp?id=2025
用javascript 自动调节iframe高度出现问题
http://www.5inet.net/HomePage/FrontPage/069775.html
窗体大小变化时,动态改变iframe高度的问题?
http://topic.youkuaiyun.com/t/20051225/21/4480578.html
提一个关于动态改变 iframe 高度的问题
http://topic.youkuaiyun.com/t/20020921/10/1041778.html