`
wenjie12201
  • 浏览: 148163 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
  • luoxun11: 其实这个问题的本质是用##包围变量的时候ibatis会采用St ...
    iBATIS #和$

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

阅读更多

html片段:

<div style="width:360px;height:100%;background:#ccc" class="panel-body">

    <iframe id="pcontframe" name="pcontframe" src="" width="100%" height="100%" frameborder="0"         scrolling="no">

    </iframe>                      

 </div>

 

js代码:

iframeHeight = function() {

var ifm = document.getElementById("pcontframe");

if (ifm != null) {

   try{

       var bHeight = ifm.contentWindow.document.body.scrollHeight;

       var dHeight = ifm.contentWindow.document.documentElement.scrollHeight;

       var height = Math.min(bHeight, dHeight);

       ifm.height = height+10;

   }catch (ex){}

}

}

 

document.getElementById("pcontframe").onload = function() {

    document.getElementById("pcontframe").height=100;

    setTimeout('iframeHeight()',200);

};

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics