test.aspx部分代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="DHCC.OCCS.Track.test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="lib/js/jquery-1.6.4.min.js"></script>//导入jquery包
<script type="text/javascript">//关闭页面是执行
var blnCheckUnload = true;
window.onbeforeunload = function () {
var mod = "logout";
var pageout = new Date().toLocaleString();
var jishu = 2;
$.get("H.ashx", { jishu: jishu, pageout: pageout,id:id });
if (blnCheckUnload) {
return ("确定离开吗?");
}
}
</script>
</head>
<body onload="add()">//加载页面时执行
</body>
</html>
<script type="text/javascript">
var id;
function add() {
var jishu = 1;
//操作系统
var os = navigator.platform ? navigator.platform : "Unkown";
//浏览器语言
var lang = navigator.systemLanguage ? navigator.systemLanguage : navigator.language ? navigator.language : "Unkown";
//浏览器分辨率
var screen = "";
if (self.screen) {
screen = window.screen.width + "*" + window.screen.height;
}
//登录时间
var pagein = new Date().toLocaleString();
//当前页面
var curUrl = document.URL ? document.URL : "";
//来源页面
var fromUrl = document.referrer ? document.referrer : "";
$.get("H.ashx", { jishu: jishu, os: os, lang: lang, screen: screen, curUrl: curUrl, fromUrl: fromUrl, pagein: pagein },function (data) { id = data });//向ashx传数据
}
</script>