iframe全屏显示

window.onload = function() {
var winWidth = parseInt(document.documentElement.clientWidth);// 客户端浏览器宽度
var winHeight = parseInt(document.documentElement.clientHeight);// 客户端浏览器高度
// iframe全屏
document.getElementById("frmDialog").width = winWidth + "px";
document.getElementById("frmDialog").height = winHeight + "px";
// iframe半屏
//document.getElementById("frmDialog").width = (winWidth / 2) + "px";
//document.getElementById("frmDialog").height = (winHeight / 2) + "px";
};

<iframe id="frmDialog" src="http://www.163.com" frameborder="0" scrolling="auto" align="top" marginheight="0" marginwidth="0"></iframe>
---------------------------------------------------------
以下方案解决最大化时自动调整iframe窗体大小问题

<!DOCTYPE html>

<html>
<head>
<title>OpenExcelInIframe</title>
<style type="text/css">
body {
margin: 0px;
}

iframe {
border: 0px;
}
</style>
<script type="text/javascript">
function resize(){
var winWidth = parseInt(document.documentElement.clientWidth);
var winHeight = parseInt(document.documentElement.clientHeight);
document.getElementById("frmDialog").width = winWidth + "px";
document.getElementById("frmDialog").height = winHeight + "px";
};
onload=function(){
resize();
};
onresize=function(){
resize();
};
</script>

</head>
<body>
<div>
<iframe src="http://www.163.com" id="frmDialog" frameborder="0" scrolling="auto" align="top" marginheight="0" marginwidth="0"></iframe>
</div>
</body>
</html>

你可能感兴趣的:(iframe)