Instance
Pageopen = new Date (); var req11= ""; var url11= "inserttime.aspx"; The server-side address to be requested if (window. XMLHttpRequest)//non-IE browser and IE7 (7.0 and later), create {req11=new XMLHttpRequest () with XMLHttpRequest object; } else if (window. ActiveXObject)//ie (6.0 and below) browsers are created with ActiveXObject objects and may fail if the user's browser disables ActiveX. {req11=new ActiveXObject ("Microsoft.XMLHTTP"); } if (REQ11)//successfully created XMLHttpRequest {req11.open ("GET", url11,true);//Set up with the server Connection (Request mode post or get, address, true for async) Req11.onreadystatechange = Callback1; Specifies the callback function req11.send (NULL); Send request} function Callback1 ()//callback function, response processing on the server, monitor response status {if (Req11.ready STATE==4)//Request Status of 4 indicates success {if (req11.status==200)//http status 200 means OK { Dispaly (); All states succeed, execute this function, display data} else//http return status failed {Alert ("Service side return status" + Req11.statustext); }} else//request status has not succeeded, the page waits {//document. getElementById ("MyTime"). innerhtm L = "Data loading"; }}function Stay () {pageclose = new Date (); minutes = (Pageclose.getminutes ()-pageopen.getminutes ()); seconds = (Pageclose.getseconds ()-pageopen.getseconds ()); Time = (seconds + (minutes * 60)); Time = (duration + "seconds"); alert (' You stay here ' + ' + '). Welcome to come again! '); var req= ""; var url= "outtime.aspx"; The server-side address to be requested if (window. XMLHttpRequest)//non-IE browser and IE7 (7.0 and later), create {req=new XMLHttpRequest () with XMLHttpRequest object; } else if (window. ActiveXObject)//ie (6.0 and below) browsers are created with ActiveXObject objects and may fail if the user's browser disables ActiveX. {req=new ActiveXObject ("Microsoft.XMLHTTP"); } if (req)//successfully created XMLHttpRequest {req.open ("GET", url,true);//Connect with server (requester Type post or GET, groundtrue = asynchronous) Req.onreadystatechange = callback; Specifies the callback function req.send (NULL); Send request} function callback ()//callback function, response processing on the server, monitor response status {if (Req.readysta TE==4)//Request Status of 4 indicates success {if (req.status==200)//http status 200 means OK {Di Spaly (); All states succeed, execute this function, display data} else//http return status failed {alert ("Server return status" + Req.statustext); }} else//request status has not succeeded, the page waits {//document. getElementById ("MyTime"). innerhtm L = "Data loading"; } }}
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class inserttime:system.web.ui.page{ protected void Page_Load (object sender, EventArgs e) { if (! IsPostBack) { SysCommon.DbSql.ExecuteSql ("INSERT into usertable (username) VALUES (' 1 ')"); } }
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class outtime:system.web.ui.page{ protected void Page_Load (object sender, EventArgs e) { if (! IsPostBack) { SysCommon.DbSql.ExecuteSql ("INSERT into usertable (username) VALUES (' 2 ')"); } }
JavaScript Record page dwell time-pass test