静态页 浏览量

javascript

2008-06-04 10:41

办法1

JS

办法2

AJAX

办法3

<iframe

1--------------------------------------------------------------------
<!--#include file="conn.asp"-->
<%id=request("id")
if isnumeric(id) then
set rsviewcount=server.CreateObject("adodb.recordset")
rsviewcount.open "select viewCount from articletable where id="&id,conn,2,3
if not rsviewcount.eof then
rsviewcount("viewCount")=rsviewcount("viewCount")+1
viewcount=rsviewcount("viewCount")+1
rsviewcount.update
else
viewcount=0
end if
rsviewcount.close
set rsviewcount=nothing
response.Write("document.write("""&viewcount&""");")
end if
%>
<script src="9.asp"></script>

2-------------------------------------------------
<script language="javascript">
var xmlHttp;
if (window.ActiveXObject){
   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest){
   xmlHttp=new XMLHttpRequest();
}
var now = new Date();
var num=now.getYear()+now.getMonth()+now.getDay()+now.getHours()+now.getMinutes()+now.getTime()

var url="/MLXZ/Click.aspx?id=306&"+num;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=yang;
xmlHttp.send(null);

function yang()
{
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
    var mes= xmlHttp.responseText;
    document.getElementById("Click").innerHTML=mes;
}
}
}
</script>
HTML <span id='click'> </span>