zoukankan      html  css  js  c++  java
  • iframe框根据内容自适应高度

    1.页面

    <iframe name="iframe_userCenter" id="iframe"  frameborder=2
             width=100% height=100% marginheight=0 marginwidth=0
             scrolling=no src="user_userMessage">
    
    </iframe>

    2.jquery实现

    <script language="javascript" type="text/javascript"> 
      $(document).ready(function(){ 
        $("#iframe").load(function(){ 
           $(this).height(0); //用于每次刷新时控制IFRAME高度初始化 
           var height = $(this).contents().height() + 20; 
           $(this).height( height < 700 ? 700 : height );  //最小的高度700
         }); 
     }); 
    </script> 

    这是自己学习过程中的记录,方便自己回顾,好记性不如烂笔头。

    作者:艺至

  • 相关阅读:
    JS
    JS
    JS
    CSS
    CSS
    CSS
    NPOI导出自动换行效果
    Httpcookie的简单应用
    前台JS设置Cookies后台读取刚设置的Cookies
    SQL SERVER 如何调试存储过程
  • 原文地址:https://www.cnblogs.com/sunjiguang/p/5148037.html
Copyright © 2011-2022 走看看