您的位置:首页 > 其它

iframe 自适应高度,兼容各浏览器

2012-03-13 14:43 330 查看
<script language="javascript" type="text/javascript">
function dyniframesize(down){
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
}else{
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight +20;
pTar.width = pTar.contentDocument.body.scrollWidth+20;
}else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
}
</script>


<iframe src ="http;//www.jcsdljj.com" frameborder="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="auto" id="ifm_dysize" name="ifm_dysize" onload="javascript:dyniframesize('ifm_dysize');" width="100%"></iframe>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: