Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.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
如何使用window.open JavaScript函数发送变量_Javascript_Php - Fatal编程技术网

如何使用window.open JavaScript函数发送变量

如何使用window.open JavaScript函数发送变量,javascript,php,Javascript,Php,使用窗口时,我想向新窗口发送一个变量。打开功能。这是我的密码: <html> <head>`enter code here` <script> function myFunction(){ window.open('test4.php?id=5', '_blank', 'toolbar=0,location=0,menubar=0'); } </script> </head> <body> <?php

使用
窗口时,我想向新窗口发送一个变量。打开
功能。这是我的密码:

<html>
<head>`enter code here`
<script>
function myFunction(){
    window.open('test4.php?id=5', '_blank', 'toolbar=0,location=0,menubar=0');
}
</script>
</head>
<body>
<?php
    $id=5;
?>
<button onclick="myFunction()">Click Here</button>
</body>
</html>

`在这里输入代码`
函数myFunction(){
open('test4.php?id=5','u blank','toolbar=0,location=0,menubar=0');
}
点击这里
PHP变量
$id=5
是我试图传递到下一页的变量。


<html>
<head>`enter code here`
 <script>
 function myFunction(value){
// getting value you want to pass
 window.open('test4.php?id=' + value, '_blank', 'toolbar=0,location=0,menubar=0');

}
 </script>
 </head>
 <body>
 <?php
 $id=6;
?>

//you can add php value in any html like that.
 <button onclick="myFunction(<?php echo $id;?>)">Click Here</button>
 </body>
 </html>
`在这里输入代码` 函数myFunction(值){ //获取您想要传递的值 open('test4.php?id='+value',_blank','toolbar=0,location=0,menubar=0'); } //您可以在任何类似的html中添加php值。