首页 > 解决方案 > 尝试使用 window.open 在 HTML 中打开一个新窗口不起作用

问题描述

当我按下按钮时,我试图打开一个新窗口,但我的代码不起作用。我收到错误“参数列表后未捕获的语法错误:缺少)”。我找不到我做错了什么

<HTML>
<body>
  <button id="open_window" onclick="window.open(https://www.google.com, height=570, width=520);"></button>
  <style>
  #open_window{
      position: fixed;
      width: 15%;
      height: 15%;
      left: 35%;
      top: 35%;
      }
  </style>
</body>
</HTML>

标签: javascripthtmlwindowsyntax-error

解决方案


网址应该被引用

 <button id="open_window" onclick="window.open('https://www.google.com', height=570, width=520);"></button>
  

推荐阅读