聘我网

新概念招聘3.0

一个js问题

vote up0vote downstar
 <script type="text/javascript"> 
    document.write('<script language="javascript" src= http://iptvdata.m189.cn/statistics.php?src='+window.location.pathname+'></'+'script>'); 
</script>

我把上面的脚本放到我要要统计的页面,获取访问的文件名来进行统计(例如http://wstar.cn/v15/,我要得到v15,再对这个文件进行统计),但是页面要刷新一下才能把数据写入数据库 请大侠们帮助一下,谢谢了

在线等待。。。。。。。。。。。

 
应该是statistics.php的问题 - Shore 2010-01-06, 00:11

1 个答复

vote up0vote downcheck

做了个简单的测试,证明第一次就能奏效:

在a.html中:

<script type="text/javascript"> 
    document.write('<script language="javascript" src= test5.php?src='+window.location.pathname+'></'+'script>'); 
</script>

test5.php中:

<?php
file_put_contents('debug.txt',$_GET['src']);

?>

然后访问a.html一次,结果生成了debug.txt,里面内容也是正确的

更新

还有一种可能是statistics.php被缓存了,防止cache可以用以下脚本:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.