Js page stay time

Source: Internet
Author: User

<Script language = "JAVASCRIPT">
<! --
Var ap_name = navigator. appName;
Var ap_vinfo = navigator. appVersion;
Var ap_ver = parseFloat (ap_vinfo.substring (0, ap_vinfo.indexOf ('(')));

Var time_start = new Date ();
Var clock_start = time_start.getTime ();
Var dl_ OK = false;

Function init ()
{
If (ap_name = "Netscape" & ap_ver >=3.0)
Dl_ OK = true;
Return true;
}

Function get_time_spent ()
{
Var time_now = new Date ();
Return (time_notesgettime ()-clock_start)/1000 );
}

Function show_secs () // show the time user spent on the side
{
Var I _total_secs = Math. round (get_time_spent ());
Var I _secs_spent = I _total_secs % 60;
Var I _mins_spent = Math. round (I _total_secs-30)/60 );
Var s_secs_spent = "" + (I _secs_spent> 9 )? I _secs_spent: "0" + I _secs_spent );
Var s_mins_spent = "" + (I _mins_spent> 9 )? I _mins_spent: "0" + I _mins_spent );
Document. fm0.time _ spent. value = s_mins_spent + ":" + s_secs_spent;
Window. setTimeout ('show _ secs () ', 1000 );
}

// -->
</Script>

Modify the <body> statement:

<BODY onLoad = "init (); window. setTimeout ('show _ secs () ', 1);">

Add the following original code between <body> </body>:

<FORM name = "fm0" onSubmit = "0"> <font color = "# 6060FF"> stay time:
</FONT> <INPUT type = "text" name = "time_spent" size = 7 onFocus = "this. blur ()"> </FORM>

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.