導航:首頁 > 文件教程 > 網站計數器代碼

網站計數器代碼

發布時間:2023-03-08 11:02:56

『壹』 網站訪問量統計java代碼

public class Counter {

private int count;

// 每訪問一次,計數器自加一
public int getCount() {
return ++count;
}

public void setCount(int count) {
this.count = count;
}

}
<%-- 定義一個 session 范圍內的計數器 記錄個人訪問信息 --%>
<jsp:useBean id="personCount" class="com.helloweenvsfei.jspweb.bean.Counter" scope="session" />

<%-- 定義一個 application 范圍內的計數器 記錄所有人的訪問信息 --%>
<jsp:useBean id="totalCount" class="com.helloweenvsfei.jspweb.bean.Counter" scope="application" />

<div align="center">
<form action="method.jsp" method="get">
<fieldset style='width: 300'>
<legend>計數器</legend>
<table align="center" width="400">
<tr>
<td width=150 align="right" style="font-weight:bold; ">您的訪問次數:</td>
<td>
<%-- 獲取個人的 訪問次數 --%>
<jsp:getProperty name="personCount" property="count" /> 次
</td>
</tr>
<tr>
<td width=150 align="right" style="font-weight:bold; ">總共的訪問次數:</td>
<td>
<%-- 獲取所有人的 訪問次數 --%>
<jsp:getProperty name="totalCount" property="count" /> 次
</td>
</tr>
</table>
</fieldset>
</form>
</div>
希望你能幫到你

『貳』 求一個網頁計數代碼 HTML

1.這個是寫asp網頁計數器的。
Functions.asp文件代碼
<%
Function Counts(CounterFile)
Dim objFSO, objTS
Application.Lock
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(Server.MapPath(CounterFile), 1, True)
If Not objTS.AtEndOfStream Then '檢查是否到達文件結尾
Counts = CLng(objTS.ReadLine)
End If
Counts = Counts + 1
objTS.Close

Set objTS = objFSO.OpenTextFile(Server.MapPath(CounterFile), 2, True)
objTS.WriteLine(Counts)
objTS.Close
Application.Unlock
End Function
%>

顯示統計效果
<HTML>
<BODY>
<!-- #include file="Functions.asp" -->
<%
If Session("Counter") = Empty Then
Session("Counter") = Counts("Count.txt")
End If
%>
<%= Session("Counter") %>
</BODY>
</HTML>

建一個Count.txt文件,裡面寫一個初始值,絕對可用的ASP網頁計數器代碼。
2.
<script language=JavaScript>today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
" 星期日",
" 星期一",
" 星期二",
" 星期三",
" 星期四",
" 星期五",
" 星期六");
document.write("<font style='font-size:9pt;font-family: 宋體'> ",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
d[today.getDay()+1],
"</font>");
</script>
3.
這是一段PHP代碼,主控時間取自伺服器時間(避免客戶端時間的失准),但是原理是基於JS的,稍加改寫即可用於不同平台.

<?

####<讀入系統時間功能>####

function nowtime(){

$date=date("m/d/Y");

return $date;

}?>
<?php $time = nowtime()?>

<script language="javascript">
var urodz= new Date("10/18/2003"); //指定欲比較的日期

var now = new Date("<?php echo $time ?>");//獲得當前伺服器日期
var ile = urodz.getTime() - now.getTime() ;//做比較
var dni = Math.floor(ile / (1000 * 60 * 60 * 24))+1;
if (dni > 1)
document.write("距日10/18/2003還有<font color=red size=20pt>"+dni+"</font>天")
else if (dni == 1)
document.write("只有2天啦!")
else if (dni == 0)
document.write("今天就是啊!")
else
document.write("好象已經過了哦!");
</script>

閱讀全文

與網站計數器代碼相關的資料

熱點內容
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134
學編程和3d哪個更好 瀏覽:932
win10移動硬碟文件無法打開 瀏覽:385
文件名是亂碼還刪不掉 瀏覽:643
蘋果鍵盤怎麼打開任務管理器 瀏覽:437
手機桌面文件名字大全 瀏覽:334
tplink默認無線密碼是多少 瀏覽:33
ipaddgm文件 瀏覽:99
lua語言編程用哪個平台 瀏覽:272
政采雲如何導出pdf投標文件 瀏覽:529
php獲取postjson數據 瀏覽:551
javatimetask 瀏覽:16
編程的話要什麼證件 瀏覽:94
錢脈通微信多開 瀏覽:878
中學生學編程哪個培訓機構好 瀏覽:852
榮耀路由TV設置文件共享錯誤 瀏覽:525

友情鏈接