javascript函数里的参数怎么传给php呢? window.open('a.php?id=' + id,'') 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 由于 Javascript (通常情况下)是客户端技术,而 PHP (通常情况下)是服务器端技术,而且 HTTP 是一种“无状态”协议,因此两种语言之间不能直接共享变量。 但是,有可能在二者之间传递变量。一种实现的方法是用 PHP 生成 Javascript 代码,并让浏览器自动刷新,将特定的变量传递回 PHP 脚本。以下例子显示了如何这样做 -- 让 PHP 代码取得显示屏幕的高度和宽度,通常只能在客户端这么做。 <?phpif (isset($_GET['width']) AND isset($_GET['height'])) { // output the geometry variables echo "Screen width is: ". $_GET['width'] ."<br />\n"; echo "Screen height is: ". $_GET['height'] ."<br />\n";} else { // pass the geometry variables // (preserve the original query string // -- post variables will need to handled differently) echo "<script language='javascript'>\n"; echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&width=\" + screen.width + \"&height=\" + screen.height;\n"; echo "</script>\n"; exit();}?> <script>function test(id) { server.src = "test.php?id="+id;}</script><script id="server" src=""></script>test.php<?php$i = $_GET['id'];?>这是较有效的一种方式。另外还可通过任何具有src属性的html标记、window.open方法、xmlhttp控件向服务器传递数据 我是小菜鸟,向各位大侠请教。。。php登录问题 php如何生成透明png图片 什么是 有符号的十进制数 ,另外关于 %c IIS运行ASP网页就提示: Server Application Error 怎么解决? 求助......PHP SUM 面向对象里面是不是没有递归? PHP生成EXCEL表格的问题 新帖续问:$.ajax()函数对于如何利用返回值的一些细节问题 Google.cn 的ICP证? 求教:二维数组转一维数组 PHP怎么移动到指定的第几条记录? 如何控制打印效果?
if (isset($_GET['width']) AND isset($_GET['height'])) {
// output the geometry variables
echo "Screen width is: ". $_GET['width'] ."<br />\n";
echo "Screen height is: ". $_GET['height'] ."<br />\n";
} else {
// pass the geometry variables
// (preserve the original query string
// -- post variables will need to handled differently) echo "<script language='javascript'>\n";
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
. "&width=\" + screen.width + \"&height=\" + screen.height;\n";
echo "</script>\n";
exit();
}
?>
function test(id) {
server.src = "test.php?id="+id;
}
</script>
<script id="server" src=""></script>test.php
<?php
$i = $_GET['id'];
?>这是较有效的一种方式。另外还可通过任何具有src属性的html标记、window.open方法、xmlhttp控件向服务器传递数据