实现iFrame自适应高度
2010-05-10 20:04
495 查看
<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 ="/default2.aspx" frameborder="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="auto" id="ifm" name="ifm" onload="javascript:dyniframesize('ifm');" width="100%">
</iframe>
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 ="/default2.aspx" frameborder="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="auto" id="ifm" name="ifm" onload="javascript:dyniframesize('ifm');" width="100%">
</iframe>
相关文章推荐
- 教你用jquery实现iframe自适应高度
- jquery 实现iframe 自适应高度
- jquery库实现iframe自适应内容高度和宽度
- JS实现iframe自适应高度的方法(兼容IE与FireFox)
- javascript原生和jquery库实现iframe自适应高度和宽度
- JS实现iframe自适应高度的方法示例
- 为何firefox不支持insertRow和insertCell。我如何能让firefox显示和ie显示的效果一样?iframe实现高度自适应,兼容FF、Opera、Safari
- 如何实现iframe高度自适应.
- 实现iframe自适应高度,原来很简单!
- iframe实现自适应高度
- 跨域实现IFRAME自适应高度~续(终级)
- 实现iFrame自适应高度,原来很简单!
- 完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】
- 实现iFrame自适应高度,原来很简单!
- jquery 实现iframe 自适应高度
- 实现iFrame自适应高度,原来很简单!
- JQuery实现iframe自适应高度
- 实现iFrame自适应高度,原来很简单!
- jquery 实现iframe 自适应高度