iframe自适应宽度

<iframe id="course_content" style="width:100%;margin:5px 0 0;" scrolling="no" src="<?php ?>" ></iframe>
 <script>
      $("#course_content").load(function() {
          var iframeHeight = $(this).contents().find("div.para").height();
          if(iframeHeight<180)
          {
              var iframeHeight = $(this).contents().find("body").height();
              $(this).height(iframeHeight+30);
          }
          else{
              //alert(iframeHeight+160);
              $(this).height(iframeHeight+160);
          }
      });
       </script> 

 

posted @ 2016-01-22 13:01  陈泽泽  阅读(979)  评论(0编辑  收藏  举报