我想发送一个变量到一个新的窗口,当使用window.open
函数。下面是我的代码:
<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>
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>
最后说明:在提出这样的问题之前,你应该先去看看这些主题的教程。