让Iframe自适应高度

<iframe src="b.html" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="100%" height="100%" id="iframepage" name="iframepage" onload="SetWinHeight(this)"></iframe> 
  
  <script type="text/javascript" language="javascript">
//<![CDATA[
  function SetWinHeight(obj)
  {
	  var win=obj;
	  if (document.getElementById)
	  {
		  if (win && !window.opera)
		  {
			  if (win.contentDocument && win.contentDocument.body.offsetHeight) 	   
				win.height = win.contentDocument.body.offsetHeight; 		
			  else if(win.Document && win.Document.body.scrollHeight)	   
				win.height = win.Document.body.scrollHeight;
		  }
	  }
  }

  //]]>
  </script>



你可能感兴趣的:(让Iframe自适应高度)