如何使用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值。