如何将参数放入window .open中的函数中

how to put argument in a function within windows.open?

本文关键字:open 函数 window 参数      更新时间:2023-09-26

我做了一个非常简单的函数,打开窗口在一定的宽度和高度,我调整。我的问题是下一个:你怎么能把我的宽度和高度参数在我的窗口。开放?我只想调用函数和参数来得到精确的测量值。因为我可能要打开3-4个不同大小的窗口…

JAVASCRIPT

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

<a href="#" onclick="ouvrirFenetre(300,200);">My link</a>

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

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