Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用变量定义宽度和高度 var w=300; var h=300; 函数openWin() { w=窗口。打开(“http://www.google.com“,“mywin”,“宽度=w,高度=h,屏幕X=50,左侧=50,屏幕Y=50,顶部=50,状态=no,菜单栏=no”); }_Javascript_Html - Fatal编程技术网

Javascript 使用变量定义宽度和高度 var w=300; var h=300; 函数openWin() { w=窗口。打开(“http://www.google.com“,“mywin”,“宽度=w,高度=h,屏幕X=50,左侧=50,屏幕Y=50,顶部=50,状态=no,菜单栏=no”); }

Javascript 使用变量定义宽度和高度 var w=300; var h=300; 函数openWin() { w=窗口。打开(“http://www.google.com“,“mywin”,“宽度=w,高度=h,屏幕X=50,左侧=50,屏幕Y=50,顶部=50,状态=no,菜单栏=no”); },javascript,html,Javascript,Html,大家好 我想知道如何在定义打开的窗口时使用我自己的变量(var w和h)。 无论我尝试什么组合,宽度和高度属性都不起作用 谢谢 您需要使用变量,而不仅仅是输入字母。像这样: var w=300; var h=300; function openWin() { w=window.open("http://www.google.com","mywin","width=w, height=h,screenX=50,left=50,screenY=50,top=50,status=no,menubar

大家好

我想知道如何在定义打开的窗口时使用我自己的变量(var w和h)。 无论我尝试什么组合,宽度和高度属性都不起作用


谢谢

您需要使用变量,而不仅仅是输入字母。像这样:

var w=300;
var h=300;

function openWin()
{
w=window.open("http://www.google.com","mywin","width=w, height=h,screenX=50,left=50,screenY=50,top=50,status=no,menubar=no");
}

<input type="button" value="Start" onclick="openWin()" />

您尚未正确关闭引号和变量赋值。
var w=300; var h=300;

function openWin()
{ 
 w=window.open("http://www.google.com","mywin","width=" + w + ", height=" + h + ", screenX=50,left=50,screenY=50,top=50,status=no,menubar=no"); 
}