【问题标题】:Using JavaScript to open a window to a specific size使用 JavaScript 打开一个特定大小的窗口
【发布时间】:2015-02-18 21:48:39
【问题描述】:

我想在单击按钮 div 时使用 window.open 方法打开一个特定大小的窗口。我参考了其他一些在线资源,并得到了它。

<div class="button" onclick="window.open('http://google.com', '_blank', 'width=600', 'height=600');return false;"></div>

我不确定我做错了什么,宽度在 Firefox 中有效,但高度却没有。它在 Chrome 中不起作用。

【问题讨论】:

  • 您是否阅读了docs 并查看示例

标签: javascript html href


【解决方案1】:

所有窗口选项都放在一个字符串中:

<div class="button" onclick="window.open('http://google.com', '_blank', 'width=600, height=600');return false;"></div>

【讨论】:

    【解决方案2】:

    下面的代码应该可以帮助您解决问题,

    <div class="button" onclick="window.open('http://google.com', '_blank', 'width=600, height=600');return false;"></div>
    

    试试看,然后告诉我。

    【讨论】:

      猜你喜欢
      • 2011-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 2013-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多