如何将在 HTML 中使用 window.open 创建的 window 调整为显示器的全宽并限制高度
how to size a window created in HTML with window.open to full width of the monitor and limit the height
我有一个代码可以打开具有特定宽度和高度的新 window。如果我输入数值它会起作用,但我想将其调整为全宽和一定高度(高度将等于宽度 x 一定比例)。我遇到的问题是我不知道如何使 window 全宽,我不知道为什么 window.width 或 window.innerwidth 不起作用。我该怎么做?
<html>
<head>
</head>
<body>
<input type="button" onclick='var myW=window.open
("http://www.google.com/","mywindow","width = window.innerWidth , height = 300");'>
</body>
</html>
您可以使用 window.screen.width
访问您的显示器尺寸,无论如何您必须以正确的方式将 window 属性 与字符串连接起来
window.open("http://www.google.com/","mywindow","width = " + window.screen.width + ", height = 300")
<input type="button" onclick='var myW=window.open ("http://www.google.com/","mywindow","width = " + window.screen.width + ", height = " + window.screen.height);'>
我有一个代码可以打开具有特定宽度和高度的新 window。如果我输入数值它会起作用,但我想将其调整为全宽和一定高度(高度将等于宽度 x 一定比例)。我遇到的问题是我不知道如何使 window 全宽,我不知道为什么 window.width 或 window.innerwidth 不起作用。我该怎么做?
<html>
<head>
</head>
<body>
<input type="button" onclick='var myW=window.open
("http://www.google.com/","mywindow","width = window.innerWidth , height = 300");'>
</body>
</html>
您可以使用 window.screen.width
访问您的显示器尺寸,无论如何您必须以正确的方式将 window 属性 与字符串连接起来
window.open("http://www.google.com/","mywindow","width = " + window.screen.width + ", height = 300")
<input type="button" onclick='var myW=window.open ("http://www.google.com/","mywindow","width = " + window.screen.width + ", height = " + window.screen.height);'>