请教:iframe怎么自适应高度? 例如我在我的网站中嵌套一个其他网页,例如http://www.sohu.com,iframe的高度如何自适应? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给 iframe 加个 onload 事件,设置高度就写在onload事件里。 现在就是不知道怎么得到iframe里那个网页的高度。 function pageWidth(){ return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null; }function pageHeight(){ return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null; }在你的子窗体中调用以上两个函数获取内容宽度跟高度,然后传给主窗口,在主窗口中设置iframe的宽度跟高度,前提是子窗体是你自己的,具有完全的控制权,否则也没啥好办法了 ~~ var doc;if (! +"\v1") //IE doc = document.frames["frame1"].document;else doc = document.getElementById("frame1").contentDocument;$('#frame1').height(doc.body.scrollHeight); 跨域的iframe不能实现自适应高度的。除非2个域名都是自己的并且可以修改里面的代码 如何判断RichTextBox中的字符是否有被选中 gridview中dropdownlist的事件 请高手们帮忙分析一下我的猴子分桃问题程序。 关于.NET多线程嵌套的管理问题 将C++中函数导入到C#中参数是数组怎么办 求助购买数量在统计的时候值为什么不改变 求一段SQL来确定当天的时间范围 怎样在VS2008里面跟踪某一个特定变量的值 关与SQL Server数据库同一程序多连接的问题,问题解决就结帖,在线等…… 在ADO.Net中操作Oracle存储过程的问题 求救 sql语句 散分,一个非常小的注册表操作
现在就是不知道怎么得到iframe里那个网页的高度。
return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight(){
return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}在你的子窗体中调用以上两个函数获取内容宽度跟高度,然后传给主窗口,在主窗口中设置iframe的宽度跟高度,前提是子窗体是你自己的,具有完全的控制权,否则也没啥好办法了 ~~
var doc;
if (! +"\v1") //IE
doc = document.frames["frame1"].document;
else
doc = document.getElementById("frame1").contentDocument;
$('#frame1').height(doc.body.scrollHeight);