代码改变世界

实现静态页面累加访问量的三种方式(1)

2010-03-04 12:06  杨延成  阅读(2421)  评论(2编辑  收藏  举报

静态页面 staticHtml.html

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>统计动态页面访问量的几种方法</title>
</head>
<body>
这是在层中显示
<div id="pv"></div>
<script src="AddNumber.aspx"></script>

</body>
</html>

 

累加页面 AddNumber.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddNumber.aspx.cs" Inherits="AddNumber" %>

 

AddNumber.aspx.cs

代码
1 public partial class AddNumber : System.Web.UI.Page
2 {
3  private static int count = 1;
4  protected void Page_Load(object sender, EventArgs e)
5 {
6 count++;
7 Response.Write("var pv=document.getElementById('pv'); pv.innerText=" + count + ";");
8 }
9 }