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

網站計數器代碼

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

閱讀全文

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

熱點內容
平板可以打開各種文件後綴的軟體 瀏覽:531
蘋果微信文件怎麼全選 瀏覽:749
手機里之前打開過的文件在哪裡找 瀏覽:685
cad能看word文件嗎 瀏覽:719
12306火車票系統後台資料庫 瀏覽:570
js翻譯德語 瀏覽:33
從哪裡可以下載a股的數據 瀏覽:437
邏輯文件名和物理文件名關系 瀏覽:66
怎麼查一個網站的外鏈 瀏覽:675
linux下db2安裝時版本選擇 瀏覽:738
匯編編程用哪個軟體 瀏覽:486
仙樂下的歌在文件管理哪裡 瀏覽:477
115網盤解析工具2014 瀏覽:371
內圓弧銑刀怎麼編程 瀏覽:410
記事本文件轉word格式對齊 瀏覽:300
excel刪除恢復文件 瀏覽:290
三星s4怎麼切換3g網路 瀏覽:994
什麼是網站維護 瀏覽:314
文件夾錄像在哪裡 瀏覽:621
可以發語音的是什麼app 瀏覽:804

友情鏈接