如何在 Google Chrome 上打开一个新的弹出窗口,该窗口可以适应任何屏幕,而无需越过 Windows 任务栏?

Kyl*_*yle 2 html javascript taskbar fullscreen

我一直在尝试创建一个适合屏幕而不与 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>
Run Code Online (Sandbox Code Playgroud)

tra*_*r53 5

事实证明,它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'");
Run Code Online (Sandbox Code Playgroud)

注意到:

  • 窗口功能字符串的MDN wiki示例似乎不正确:包含所需功能的名称并忽略不需要的功能。

  • 用户可能有选择地禁用了对 widow.open 功能的抑制。(在 Mozilla Firefox 中,请参阅about:config下文dom.disable_window_open_feature以防止弹出窗口隐藏位置详细信息或禁用其他有用的功能。)