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

網站計數器代碼

發布時間: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>

閱讀全文

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

熱點內容
js傳值到超鏈接裡面 瀏覽:608
編程中的w和h是什麼 瀏覽:313
資料庫切了什麼意思 瀏覽:213
如何登錄極路由器設置密碼 瀏覽:522
jsp用戶登陸密碼加密源代碼 瀏覽:629
everfilter使用教程 瀏覽:768
作業票文件名稱是什麼 瀏覽:463
私密文件忘記密碼 瀏覽:686
藏文軟體app怎麼可以下載 瀏覽:960
鍵盤文件名 瀏覽:538
電腦自帶驅動在那個文件夾 瀏覽:531
c窗體讀取文件夾 瀏覽:965
asp婚紗攝影網站 瀏覽:684
文件恢復的原理 瀏覽:828
移動硬碟清空怎麼恢復數據 瀏覽:433
文件保存電腦桌面英文 瀏覽:128
debian共享文件夾 瀏覽:633
平安易貸不用app怎麼審核 瀏覽:883
如何學習編程環境 瀏覽:335
榮耀6升級60 瀏覽:281

友情鏈接