【问题标题】:I want to open the new window in browser on the click of button in maximize mode我想在最大化模式下单击按钮在浏览器中打开新窗口
【发布时间】:2020-01-23 19:22:44
【问题描述】:

我尝试了window.open() 和resizeTo(screen.width,screen.height),但它没有以最大化视图打开。

请帮助提供相关代码。

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

您只能resizeTo() 由window.open() 创建的窗口。首先,您应该创建并写入任何 var 您的窗口实例。之后你可以使用它的方法。这是一个例子:

myExternalWindow = window.open("http://myurl.domain", "myWindowName", "resizable");
myExternalWindow.resizeTo(screen.availWidth,screen.availHeight);

祝你好运!

【讨论】:

  • JavaScript 无法缩小或最大化窗口。这些操作系统级别的功能对前端开发人员是隐藏的。 source 或 another-source
【解决方案2】:

尝试使用 screen.availHeight / screen.availWidth 的 window.open。

例如

window.open(src, "newWin", "width="+screen.availWidth+",height="+screen.availHeight)

【讨论】:

  • 它将打开一个最大尺寸的新页面,而不是最大化模式
【解决方案3】:

您将打开的窗口(我认为您的意思是弹出窗口)的大小可以通过 width 和 height 属性设置,如下所示:

<a href="your-http-address.php" onclick="window.open(this.href,'targetWindow',
  'toolbar=no,
   location=no,
   status=no,
   menubar=no,
   scrollbars=yes,
   resizable=yes,
   width=your_width,
   height=your_height');
 return false;">Open PopUp Window</a>

占位符 your_width 和 your_height 指定弹出窗口的尺寸。要使弹出窗口覆盖整个屏幕尺寸,只需使用 screen.availWidth 和 screen.availHeight。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-24
    • 1970-01-01
    • 2023-04-07
    • 2015-09-09
    • 1970-01-01
    相关资源
    最近更新 更多