Iframe自适应高度兼容ie,firefox多浏览器
(编辑:jimmy 日期: 2024/11/7 浏览:3 次 )
复制代码 代码如下:
<script type="text/javascript">
function SetCwinHeight(){
var bobo=document.getElementById("bobo"); //iframe id
if (document.getElementById){
if (bobo && !window.opera){
if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
bobo.height = bobo.contentDocument.body.offsetHeight;
}else if(bobo.Document && bobo.Document.body.scrollHeight){
bobo.height = bobo.Document.body.scrollHeight;
}
}
}
}
</script>
<iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="/UploadFiles/2021-04-02/default.asp?cateID=1">
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
<script type="text/javascript">
function SetCwinHeight(){
var bobo=document.getElementById("bobo"); //iframe id
if (document.getElementById){
if (bobo && !window.opera){
if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
bobo.height = bobo.contentDocument.body.offsetHeight;
}else if(bobo.Document && bobo.Document.body.scrollHeight){
bobo.height = bobo.Document.body.scrollHeight;
}
}
}
}
</script>
<iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="/UploadFiles/2021-04-02/default.asp?cateID=1">
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
下一篇:自定义标签实现圆角边框