iframe自适应高度,360 6.2代码不兼容怎么办?
iframe自适应高度,3606.2代码不兼容怎么办?代码是:<iframesrc="hh.html"width="100%"height="100%"align="ce...
iframe自适应高度,360 6.2代码不兼容怎么办?
代码是:<iframe src="hh.html" width="100%" height="100%" align="center" id="index_10" name="index_10" onload="Javascript:SetCwinHeight()" frameborder="0" scrolling="no"></iframe>
我用的是这段,是正常的,就360 6.2高度显示一点,求指点
<script language="JavaScript" type="text/JavaScript">
function SetCwinHeight()
{
var cwin=document.getElementById("index_10");
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
</script> 展开
代码是:<iframe src="hh.html" width="100%" height="100%" align="center" id="index_10" name="index_10" onload="Javascript:SetCwinHeight()" frameborder="0" scrolling="no"></iframe>
我用的是这段,是正常的,就360 6.2高度显示一点,求指点
<script language="JavaScript" type="text/JavaScript">
function SetCwinHeight()
{
var cwin=document.getElementById("index_10");
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
</script> 展开
1个回答
展开全部
<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("frame_content");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight); //一个ff 一个ie 取大值兼容
iframe.height = height;
document.getElementById('btn1').onclick=function(){alert(dHeight)};
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);//定时刷新重取 经测试对cpu 没啥影响
</script>
添加脚本,注意iframe的id,这样在360急速模式下本地还是不兼容的,放到服务器上测试就可以了
function reinitIframe(){
var iframe = document.getElementById("frame_content");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight); //一个ff 一个ie 取大值兼容
iframe.height = height;
document.getElementById('btn1').onclick=function(){alert(dHeight)};
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);//定时刷新重取 经测试对cpu 没啥影响
</script>
添加脚本,注意iframe的id,这样在360急速模式下本地还是不兼容的,放到服务器上测试就可以了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询