拖拽窗口iframe也可以自适应高度

方案一

<iframe name="myiframe" id="myiframe" src="#" frameborder="0" scrolling="no"></iframe>
<script type="text/javascript" language="javascript">
	$(window.parent.document).find("#myiframe").load(function(){
		var main = $(window.parent.document).find("#myiframe");
		var thisheight = $(document).height()+30;
		main.height(thisheight);
	});
</script>

方案二

 

<iframe name="myiframe" id="myiframe" src="#" frameborder="0" scrolling="no"></iframe>
<script type="text/javascript" language="javascript">
	function changeFrameHeight(){
		var ifm= document.getElementById("myiframe");
		ifm.height=document.documentElement.clientHeight-56;
	}
	window.onresize=function(){ changeFrameHeight();}
	$(function(){changeFrameHeight();});
</script>

 

发表回复

后才能评论