iframe auto height and width

<html >
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
	<style type="text/css">
		html body{
		width:100%;
		height:100%;
		padding:0px;
		margin:0px;
		overflow:hidden;
		}
	</style>
</head>
<body>
 
<div class="page">
<div class="content">
   <!-- header start-->
   <div class="header" id="header-bar">
   <!--top bar content--->
  </div>
  <!--header end -->
 
    <div class="center">
      <iframe id="sites-frame" src="http://www.baidu.com/" name="sites-frame" frameborder="0" noresize="noresize" width="100%">
      </iframe>
    </div>
 
   </div>
</div>
<!--page end -->
s<script type="text/javascript">
 
      //function to fix height of iframe!
      var calcHeight = function() {
        var headerDimensions = $('#header-bar').height();
        $('#sites-frame').height($(window).height() - headerDimensions);
      }
 
      $(document).ready(function() {
        calcHeight();
      });
 
      $(window).resize(function() {
        calcHeight();
      }).load(function() {
        calcHeight();
      });
</script>
</body>
</html>

 

你可能感兴趣的:(iframe)