iframe 自动适应页面高度

来源:互联网 发布:淘宝怎么批量发货 编辑:程序博客网 时间:2024/06/07 07:56

js实现方法:

 

function SetHeight(obj)
 {
   var cwin=obj;
   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;
     }
   }
 }

 

 

 

<iframe width="610" height="10" onload='Javascript:SetHeight(this)' src="<bean:write name="htmlurl" scope="request"/>"  frameborder="0" align="center"/>

原创粉丝点击