Javascript language

adplus-dvertising
Measuring users time on a pag
Previous Home Next

Measuring users time on a page using Java Script

Step 1. Written below code in your application.
<html>
<body bgcolor=ffffff onLoad='personIN()' onUnLoad='personOut()'>
<script language="javascript">
function personIN() {
   enter=new Date();
}
function personOut() {
   exit=new Date();
   time_dif=(exit.getTime()-enter.getTime())/1000;
   time_dif=Math.round(time_dif);
   alert ("You've only been here for: " + time_dif + " seconds!!")
}
</script>
</body>
</html>

Step 2. Run the Application.

Previous Home Next