获取用户在页面上停留时间。
请问如何获取计算用户在页面的停留时间?
[解决办法]
<form name=forms> <font size=3><CENTER><div align=center></font><font color=red size=3>您在本页停留了</font><font color=#80FF80>
<input type=text name=input1 size=10></font>
</div></center></font>
<SCRIPT language=javascript><!--
var sec=0;var min=0;var hou=0;flag=0;idt=window.setTimeout("update();",1000);function
update(){sec++;if(sec==60){sec=0;min+=1;}if(min==60){min=0;hou+=1;}if((min>0)&&(flag==0)){window.
alert("你已经在本页停留了1分钟!");flag=1;}
document.forms.input1.value=hou+"时"+min+"分"+sec+"秒";idt=window.setTimeout("update();",1000);}
//-->
</SCRIPT>
</form>
<script language="C#" runat=server>
DateTime startTime;
void Page_Init (Object sender, EventArgs e) //页面加载
{
startTime = DateTime.Now;
//Response.Write("page init<br/>");
}
protected override void Render(HtmlTextWriter writer) //加载结束
{
base.Render(writer);
DateTime endTime = DateTime.Now;
Response.Write("done in " + (endTime-startTime));
}
</script>