在自己工作中,一些功能特效同大家一起分享……

防止软件刷js代码
<%--防止软件刷网页--%>
<script src="../Script/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
var movetimes = 0; //移动次数
$(document).mousemove(function (even) {
movetimes++;
if (movetimes > 100) { //事件被执行次数大于n,设置个比较保守的值
$(document).unbind("mousemove"); //解除mousemove绑定
//此处执行异步提交数据,使用POST形式提交请求
alert("异步提交记录请求!");
}
});
});

//通过Cookie记录游客IP5分钟内,浏览次数不会增加

 protected void Page_Init(object sender, EventArgs e)
{
//记录游客的IP及cookie
string userIp =Page.Request.UserHostAddress.ToString();
if (Request.Cookies["userIp"] == null)
{
HttpCookie cookieIp = new HttpCookie("userIp");
DateTime dtNow = DateTime.Now;
TimeSpan tsTime = new TimeSpan(0, 0, 300);//cookie的存活期是60秒
cookieIp.Expires = dtNow + tsTime;
Response.Cookies.Add(cookieIp);
//浏览次数+1(更新)
int supplyID = int.Parse(Request.QueryString["SupplyID"].ToString());
string updateHits = "update SupplyInfo set Hits=Hits+1 where SupplyID=" + supplyID;
DataAccess.DC.ExecSqlReturn(updateHits);
}

}