问题:
很多应用系统为了获取最大化的工作区域,经常需要将浏览器窗口本身的菜单、工具条等隐藏。
解决方案:
首先打开一个中转页面,在该页面中使用window.open方法打开一个最大化的窗口,并且在该窗口中将父窗口关闭。这样对于用户而言,看到的就是一个自动最大化的浏览器窗口。

Code
//1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>1</title>
<script type="text/javascript">
function init()
{
var options = "status=yes,resizable=yes,left=0,top=0,width=" + (screen.availWidth-8) + ",height=" + (screen.availHeight-56);
window.open("2.html","_blank",options);
}
function closeWin(){
window.opener = null;
window.open('','_self');
window.close();
}
</script>
</head>
<body onload=init()>
</body>
</html>

Code
//2.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>2</title>
<script type="text/javascript">
function init()
{
window.opener.closeWin();
}
</script>
</head>
<body onload=init()>
<h1>2</h1>
</body>
</html>
在IE6中可以采用如下JS代码可以无提示关闭窗口:

Code
window.opener = null;
window.close();
但在IE7中失效,必须再加上一行代码:

Code
window.opener = null;
window.open('','_self');
window.close();
此法也适用火狐浏览器。