Skip to content

Instantly share code, notes, and snippets.

@dharma017
Created August 14, 2013 09:14
Show Gist options
  • Save dharma017/6229296 to your computer and use it in GitHub Desktop.
Save dharma017/6229296 to your computer and use it in GitHub Desktop.
<!-- Paste this code into an external JavaScript file named: timePage.js -->
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Cody Shaffer :: http://codytheking313.byethost11.com */
var 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!");
}
<!-- Paste this code into the HEAD section of your HTML document.
You may need to change the path of the file. -->
<script type="text/javascript" src="timePage.js"></script>
<!-- Paste this code into the BODY tag -->
<body onload='window.setInterval("timeHere()", 100)' onunload="sayTime()">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment