我一直在尝试创建一个适合屏幕的弹出窗口,而不会重叠Windows'任务栏,我已经完成了一些研究,甚至创建了HTML文件,但它并没有完全正常工作,它与任务栏重叠,甚至超越了它。如何实现这样的任务,我做错了什么?
代码:(在桌面上运行)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>winds</title>
</head>
<body>
<script>
function fc()
{
window.open('http://www.google.com.br','window','menubar=yes,screenX=0,screenY=0,top=0,left=0,location=no,status=no,toolbar=no,scrollbars=yes,resizable=no,width=' + (screen.width - 10) + ',height=' + screen.availHeight);
}
</script>
<a href="JavaScript:fc()">Chrome</a>
</body>
</html>
&#13;
答案 0 :(得分:2)
事实证明window.outerWidth
和window.outerHeight
已经存在了一段时间,但直到IE9才出现在IE中。
以下代码示例打开一个窗口,其中包含最大尺寸但没有任务栏,首先打开最小尺寸,然后调整打开的窗口大小以占用所有可用区域。
function splashOpen(url)
{
var winFeatures = 'screenX=0,screenY=0,top=0,left=0,scrollbars,width=100,height=100';
var winName = 'window';
var win = window.open(url,winName, winFeatures);
var extraWidth = win.screen.availWidth - win.outerWidth;
var extraHeight = win.screen.availHeight - win.outerHeight;
win.resizeBy(extraWidth, extraHeight);
return win;
}
// and test
splashOpen("javascript:'hello folks and world'");
注意到:
MDN wiki example of a window features string似乎不正确:包含所需功能的名称,并省略不需要的功能。
用户可以选择性地禁用对widow.open功能的抑制。 (在Mozilla Firefox中,请参阅about:config
下的dom.disable_window_open_feature
,以防止弹出窗口隐藏位置详细信息或禁用其他有用功能。)