我正在尝试通过按钮打开一个新窗口。窗口需要具有特定的高度和宽度。每当我单击“打开”按钮时,它只会打开一个全新的标签。
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>
答案 0 :(得分:1)
window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300px,height=300px');
尝试此代码进行测试
答案 1 :(得分: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')
答案 2 :(得分: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>