如何根据加载页面自动改变iframe的高度 给出几个链接 控制iframe加载的内容不同大小也不同,如何根据加载的不同来控制iframe的高度呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <iframe id="frame_content1" src="new_neiye/new_zhongzujieshao.htm" width="1002" scrolling="no" frameborder="0" allowtransparency="ture" onload="this.height = '100px';"></iframe> <script type="text/javascript"> function reinitIframe(){ var iframe = document.getElementById("frame_content1"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.height = height; }catch (ex){} } window.setInterval("reinitIframe()", 200); </script> 在加载页面,设置iframe的高度就可以了。 document.getElementById("iframeId").height = Math.max(document.getElementById("iframeId").contentWindow.document.body.scrollHeight,document.getElementById("iframeId").contentWindow.document.documentElement.scrollHeight). 楼上的说的控制我都懂,但是我的要求是内部页面出现变化的时候,iframe大小也随之发生变化,如何才能有效的控制呢,意思也就是说iframe高度随着内部加载页面内容高度变化而变化,相当于内部的加载页面来处理主窗体的这个iframe 举个例子 加载数据的话 有两页,第一页就是标准大小,当下一页的时候(在内嵌的页面的处理),第二页的数据少 页面也小了 这时候如何让iframe的大小也随之变化呢 iframe比较麻烦吧用div可以的 视频流是如何由服务器端传送到网页端并播放出来的 jquery问题 如何分离JS FUNCTION? html 纯js 实现带热点图片在规定区域内的拖动 (效果类似地图拖动) 请教《Ajax基础教程》的一个例子——使用innerHTML属性创建动态内容 如何想js文件里面传递变量? 请过来看看,这是什么意思? 求一段javascript(很菜的): Google Chrome最新版本v37不支持showModalDialog了? webfx的DHTML MENU4,同样的代码在html中正常显示,但是jsp中确不显示异常? 怎么判断数字的范围呢? jquery 复制函数的应用
<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("frame_content1");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);
</script>
用div可以的