我如何在 Google Chrome 上打开一个新的弹出窗口 window 以适应任何屏幕而无需越过 Windows' 任务栏?
How can I open a new popup window on Google Chrome that adjusts to any screen without going over Windows' taskbar?
我一直在尝试创建一个适合屏幕的弹出启动器而不重叠 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>
事实证明 window.outerWidth
and window.outerHeight
已经有一段时间了,但直到 IE9 才出现在 IE 中。
下面的代码示例打开一个最大尺寸但没有任务栏的 window,方法是首先以最小尺寸打开它,然后调整打开的 window 的大小以占据所有可用区域。
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 中,请参阅 dom.disable_window_open_feature
下的 about:config
以防止弹出窗口隐藏位置详细信息或禁用其他有用的功能。)
我一直在尝试创建一个适合屏幕的弹出启动器而不重叠 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>
事实证明 window.outerWidth
and window.outerHeight
已经有一段时间了,但直到 IE9 才出现在 IE 中。
下面的代码示例打开一个最大尺寸但没有任务栏的 window,方法是首先以最小尺寸打开它,然后调整打开的 window 的大小以占据所有可用区域。
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 中,请参阅
dom.disable_window_open_feature
下的about:config
以防止弹出窗口隐藏位置详细信息或禁用其他有用的功能。)