Javascript 如何在windows.open中的函数中放置参数?

Javascript 如何在windows.open中的函数中放置参数?,javascript,html,Javascript,Html,我做了一个非常简单的函数,可以在我调整的某个宽度和高度打开窗口。 我的问题是下一个:如何将我的宽度和高度参数放入我的windows.open?我只想调用函数和参数来获得精确的测量值。因为我可能会有3-4个不同大小的窗口来打开 JAVASCRIPT function ouvrirFenetre(width,height){ window.open('formulaire.php','mywin','left=20,top=20,width='width',height='height'')

我做了一个非常简单的函数,可以在我调整的某个宽度和高度打开窗口。 我的问题是下一个:如何将我的宽度和高度参数放入我的windows.open?我只想调用函数和参数来获得精确的测量值。因为我可能会有3-4个不同大小的窗口来打开

JAVASCRIPT

function ouvrirFenetre(width,height){
    window.open('formulaire.php','mywin','left=20,top=20,width='width',height='height'');
}
HTML


您必须使用
+
符号将字符串与变量连接起来。尝试:

function ouvrirFenetre(width,height){
    window.open('formulaire.php','mywin','left=20,top=20,width=' + width + ',height=' + height);
}

随机附带说明:我将浏览器设置为始终在当前窗口中以选项卡的形式打开新窗口,使窗口大小不相关;)
function ouvrirFenetre(width,height){
    window.open('formulaire.php','mywin','left=20,top=20,width=' + width + ',height=' + height);
}