js Iframe 自动适应 高度 宽度
来源:互联网 发布:电子书阅读软件哪个好 编辑:程序博客网 时间:2024/05/17 08:24
/* File Created: 十一月 25, 2011 */
//使用方法 在iframe的onload事件中加载
//<iframe onload="reinitIframe(this)" id="frame_content" src="Default2.aspx" width="100" frameborder="0" height="100%"
// scrolling="no"></iframe>
//iframe 高度自适应
function IFrameReSize(iframename) {
var pTar = document.getElementById(iframename);
if (pTar) { //ff
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
pTar.height = pTar.contentDocument.body.offsetHeight;
} //ie
else if (pTar.Document && pTar.Document.body.scrollHeight) {
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
//iframe宽度自适应
function IFrameReSizeWidth(iframename) {
var pTar = document.getElementById(iframename);
if (pTar) { //ff
if (pTar.contentDocument && pTar.contentDocument.body.offsetWidth) {
pTar.width = pTar.contentDocument.body.offsetWidth;
} //ie
else if (pTar.Document && pTar.Document.body.scrollWidth) {
pTar.width = pTar.Document.body.scrollWidth;
}
}
}
//iframe 高度自适应
function reinitIframe(iframeid) {
var iframe = document.getElementById(iframeid);
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);
- js Iframe 自动适应 高度 宽度
- Iframe自动适应宽度和高度
- iframe 自动适应子页面高度宽度
- iframe高度自动适应
- iframe自动适应高度
- iframe 高度自动适应
- Iframe自动适应高度
- iframe高度自动适应
- IFRAME 自动适应高度
- Iframe自动适应高度
- iframe自动适应高度
- iframe自动适应高度
- iframe 自动适应高度
- iframe 自动适应高度
- iframe高度自动适应
- iframe高度自动适应
- iframe 自动适应高度
- iframe自动适应高度
- 博客推荐
- tcp 协议细节
- Javascript学习(二)——事件
- 用web.xml控制Web应用的行为(4)
- JPA与Hibernate的优缺点
- js Iframe 自动适应 高度 宽度
- 用web.xml控制Web应用的行为(5)
- EIP、ESP、EBP
- ToolBar的Button上使用ToolTip的方法(SDK)
- Decorator 模式
- 重写BaseAdapter的样例
- Flex set和get关键字用法
- java实现快速排序
- 用web.xml控制Web应用的行为(5)-2