哪位老板有iframe[高度和宽度]自适应的相关代码?img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/10.gif][/img]
以下这段代码是我现在正在用的,在IE7,IE8下面没问题.但是在其他浏览器下就不行了.想找一个不求完美但求兼容性稍好点儿的.网上我都找得差不多了,就那几种,各位大神手上有没有存货啊!
<script type="text/javascript" language="javascript">
<!--
function TuneHeight(fm_name,fm_id){
var frm=document.getElementByIdx(fm_id);
var subWeb=document.frames?document.frames[fm_name].document:frm.contentDocument;
if(frm != null && subWeb != null){
frm.style.height = subWeb.documentElement.scrollHeight+"px";
//如需自适应宽高,去除下行的“//”注释即可
// frm.style.width = subWeb.documentElement.scrollWidth+"px";
}
}
//-->
</script>
<iframe
onLoad="{TuneHeight('FM_Name','FM_Id');}"
src="http://www.oyksoft.com" name="FM_Name"
id="FM_Id" width="800" marginwidth="0"
marginheight="0"
frameborder="0" scrolling="no">
</iframe>
以下这段代码是我现在正在用的,在IE7,IE8下面没问题.但是在其他浏览器下就不行了.想找一个不求完美但求兼容性稍好点儿的.网上我都找得差不多了,就那几种,各位大神手上有没有存货啊!
<script type="text/javascript" language="javascript">
<!--
function TuneHeight(fm_name,fm_id){
var frm=document.getElementByIdx(fm_id);
var subWeb=document.frames?document.frames[fm_name].document:frm.contentDocument;
if(frm != null && subWeb != null){
frm.style.height = subWeb.documentElement.scrollHeight+"px";
//如需自适应宽高,去除下行的“//”注释即可
// frm.style.width = subWeb.documentElement.scrollWidth+"px";
}
}
//-->
</script>
<iframe
onLoad="{TuneHeight('FM_Name','FM_Id');}"
src="http://www.oyksoft.com" name="FM_Name"
id="FM_Id" width="800" marginwidth="0"
marginheight="0"
frameborder="0" scrolling="no">
</iframe>
解决方案 »
- .net中repeater中的Image问题。。。急求~~~~~
- 按钮点击后如何新打开页面进行提交?
- 如何计算出两个日期格式的字符串相差几天
- skin & theme(皮肤和主题)的问题
- 怎样把两个字段的信息内容绑定到 DropDownList的 DataTextField 属性?
- 那里能下到.net Framework 2.0的中文版??
- datatable 回发后自动清空?
- DataGrid数据不刷新
- 在线等待:哪位做个无限级树型目录的.给小弟发一份过来.
- 这个机试题,增删改查都在dataset 中执行,是什么意思。
- webservice发布问题
- 关于OnClientClick="return checkform();"
try {
var bHeight = obj.contentWindow.document.body.scrollHeight;
var dHeight = obj.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
obj.height = height;
} catch (ex) { }
}
<iframe frameborder="0" width="100%" src="demo.html" id="IFrame" scrolling="no" onload="initIframe(this);"></iframe>