如何在JavaScript中实现命中计数器?

时间:2017-05-22 16:57:51

标签: javascript web-services cookies idioms hitcounter

一般来说,PHP样式Hit Counter如何在JavaScript中实现?

这个PHP example

<?php

/* counter */

//opens countlog.txt to read the number of hits
$datei = fopen("/countlog.txt","r");
$count = fgets($datei,1000);
fclose($datei);
$count=$count + 1 ;
echo "$count" ;
echo " hits" ;
echo "\n" ;

// opens countlog.txt to change new hit number
$datei = fopen("/countlog.txt","w");
fwrite($datei, $count);
fclose($datei);

?>

在服务器上运行,而不是像JavaScript一般在浏览器中运行。

0 个答案:

没有答案