Window.open 个问题 html

Window.open problems in html

我正在尝试使用按钮打开一个新的 window。 window 需要有特定的高度和宽度。每当我单击 "open" 按钮时,它只会打开一个全新的选项卡。

var aWindow;

function openWindow() {
  aWindow = window.open("", "", "width=400, height = 200");
}

function closeWindow() {
  if (aWindow) {
    aWindow.close();
  }
}
<html>

<body>
  <button onclick="openWindow();">Open</button>
  <button onclick="closeWindow();">Close</button>
</body>

</html>

window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300px,height=300px');

试试这个代码测试

尝试使用此代码

 window.open('https://www.google.co.in/','_blank','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes,resizable=yes, width=10px, height=20px')

DEMO LINK

<input type="button" value="Open a Popup Window" onclick="popupFunction('https://whosebug.com')">

<script>
    // Popup window function
    function popupFunction(url) {
popupWindow = window.open(url,'popUpWindow','height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');
    }
</script>