JavaScript Record page dwell time-pass test

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.