top alert




JavaScript Source Code 3000: Page Details: Time On Page (Alert)

































Time On Page (Alert)








If you want to show your visitors how long they have been on your page but don't exactly like those clock displays, then you might like this script. When the visitor leaves or clicks the button, they are alerted to the time they have been on your page. Many times, they won't even expect it!














JavaScript Source Code 3000: Page Details: Time On Page (Alert)
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as NotePad or SimpleText) and save (Control-s or Apple-s). The script is yours!




    





<!-- THREE STEPS TO INSTALL TIME ON PAGE (ALERT):

1. Paste the coding into the HEAD of your HTML document
2. Copy the onLoad event handler into the BODY tag
3. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<! >
<! >

<!-- Begin
var onHours = " ";
var onMinutes = " ";
var onSeconds = " ";
var offHours = 0;
var offMinutes = 0;
var offSeconds = 0;
var logSeconds = 0;
var logMinutes = 0;
var logHours = 0;
var OnTimeValue = " ";
var OffTimeValue = " ";
var PageTimeValue = " ";

function getLogonTime() {
var now = new Date();
var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
var Hours = now.getHours();
Hours = ((Hours > 12) ? Hours - 12 : Hours);
var Minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
var Seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
OnTimeValue =(" "
+ Hours
+ Minutes
+ Seconds
+ " "
+ ampm);
onHours = now.getHours();
onMinutes = now.getMinutes();
onSeconds = now.getSeconds();
}
function getLogoffTime() {
var now = new Date();
var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
var Hours = now.getHours();
Hours = ((Hours > 12) ? Hours - 12 : Hours);
var Minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
var Seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
OffTimeValue =(" "
+ Hours
+ Minutes
+ Seconds
+ " "
+ ampm);
offHours = now.getHours();
offMinutes = now.getMinutes();
offSeconds = now.getSeconds();
timer();
}
function timer() {
if (offSeconds >= onSeconds) {
logSeconds = offSeconds - onSeconds; }
else {
offMinutes -= 1;
logSeconds = (offSeconds + 60) - onSeconds;
}
if (offMinutes >= onMinutes) {
logMinutes = offMinutes - onMinutes; }
else {
offHours -= 1;
logMinutes = (offMinutes + 60) - onMinutes;
}
logHours = offHours - onHours;
logHours = ((logHours < 10) ? "0" : ":") + logHours;
logMinutes = ((logMinutes < 10) ? ":0" : ":") + logMinutes;
logSeconds = ((logSeconds < 10) ? ":0" : ":") +logSeconds;
PageTimeValue =(" "
+ logHours
+ logMinutes
+ logSeconds);
displayTimes();
}
function displayTimes() {
alert("\nLOG ON TIME : " +OnTimeValue+"\n\nLOG OFF TIME : "+OffTimeValue+"\n\nTIME ON PAGE : " + PageTimeValue);
}
// End -->
</SCRIPT>

<!-- STEP TWO: Add this onLoad event handler into the BODY tag -->

<BODY onLoad="getLogonTime()">

<!-- STEP THREE: Put this code into the BODY of your HTML document -->

<CENTER>
<FORM>
<INPUT TYPE="button" value="Time on Page" onClick="getLogoffTime()">
</FORM>
</CENTER>



<!-- Script Size: 2.92 KB -->











Wyszukiwarka

Podobne podstrony:
VA US Top 40 Singles Chart 2015 10 10 Debuts Top 100
border top color
Moja Cyganko Cyganie Tip Top
top
Top Secret Packing Heat
top summary
AdorabellePlushies Peanut Big Top Type Doll
alert button
Instrukcja naprawy Air Top 3500ST?
1416555285 top
Top Gear S18E02 HDTV XviD FoV

więcej podobnych podstron