Full version: jsB@nk » Time » Time Spent on Page
URL: https://www.javascriptbank.com/time-spent-on-page.html
This JavaScript displays an alert message when a page is closed, telling the visitor how long (in seconds) they have been on the page. It can also display the time on the page in the title bar.
Full version: jsB@nk » Time » Time Spent on Page
URL: https://www.javascriptbank.com/time-spent-on-page.html
<script type="text/javascript" name="timePage.js">// Created by: Cody Shaffer :: http://codytheking313.byethost11.comvar time=1;function timeHere() { time = time + 1; finalTime = time / 10;/* Remove the "//" below to display in the title bar the amount of time the visitor has been on the site. Be aware though, that it does tend to be a bit distracting. */// document.title = finalTime+" seconds you been here for!";}function sayTime() { finalTime = time / 10; alert("Thank you for coming to my site! \n You have been here " + finalTime + " seconds!");}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<body onload='window.setInterval("timeHere()", 100)' onunload="sayTime()"><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->