真正的讓iframe自適應高度 兼容多種瀏覽器隨着窗口大小改變


http://blog.csdn.net/alex8046/article/details/51456131

<!DOCTYPE html>
<html lang="zh">
<head>
	<title>{$config.site_name}</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="keywords" content="{$config.site_keywords|escape:html}" />
	<meta name="description" content="{$config.site_description|escape:html}" />
	<LINK href="/static/css/reset.css" type=text/css rel=stylesheet>
	<LINK href="/static/css/gameplay.css" type=text/css rel=stylesheet>
	<script type="text/javascript" src="/static/js/jquery.min.js"></script>
	<script>
		{literal}
		$(function(){
				adjustWidthHeight();
		});
		function adjustWidthHeight() {
				var width = $(window).width(); //瀏覽器當前窗口可視區域寬度
				var height = $(window).height();
				$("#g_canvas").width(width - 50);
				$("#g_canvas").height(height - 40);
				//$('#gameifr').width(width - 50);
				//$('#gameifr').height(height - 40);
		}
		$(window).resize(function () {
				adjustWidthHeight();
		});
		{/literal}
	</script>
</head>
<body>
<div class="top">
這是頭部
</div>
<div id="g_canvas">
<iframe id="gameifr" scrolling="auto" src="{$game_login_gateway}" frameborder="no" width="100%" height="100%" style="overflow: auto;"></iframe>
</div>
</body>
</html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM