如何自动获取Iframe自动高度

飘逸的风14年前 (2012-11-15)前端6675
js部分:

<script type="text/javascript"> 
function SetCwinHeight(iframeObj){ 
if (document.getElementById){ 
   if (iframeObj && !window.opera){ 
    if (iframeObj.contentDocument && iframeObj.contentDocument.body.offsetHeight){ 
     iframeObj.height = iframeObj.contentDocument.body.offsetHeight; 
    }else if(document.frames[iframeObj.name].document && document.frames[iframeObj.name].document.body.scrollHeight){ 
     iframeObj.height = document.frames[iframeObj.name].document.body.scrollHeight; 
    } 
   } 
</script> 

html网页部分

<iframe src="https://www.yiwangdajin.com" name="frameContent" scrolling="auto" frameborder="no" width="799" onload="SetCwinHeight(this)"></iframe>

相关文章

escape()、encodeURI()、encodeURIComponent()区别详解

JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod...

屏蔽js错误信息

在IE下经常有那个恼人的“网页上有错误”的提示,自己看到很闹心。相信初级用户看到很害怕。不过这个问题也是可以解决的!看看renaski的解决方案。 <script> window....

js判断undefined类型,undefined,null,NaN的区别

js判断undefined类型 今天使用showModalDialog打开页面,返回值时。当打开的页面点击关闭按钮或直接点浏览器上的关闭则返回值是undefined 所以自作聪明判断&nb...

实现jQuery扩展总结

开发自己需要的jQuery插件,看个示例说明 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://...

jquery简单代码实现复选框多选、单选、全不选功能,很实用

<html> <head>  <script type="text/javascript" src="https://code.jquery.com/jqu...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。