HTML中的Window.open问题[重复]

问题描述 投票:-1回答:3

这个问题在这里已有答案:

我想用一个按钮打开一个新窗口。窗口需要具有特定的高度和宽度。每当我点击“打开”按钮,它就会打开一个全新的标签。

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>
javascript html window.open
3个回答
0
投票

尝试使用此代码

 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


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

试试这个代码测试


0
投票
<input type="button" value="Open a Popup Window" onclick="popupFunction('https://stackoverflow.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>
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.