• Problems

    This line enable URL Rewriting . It must be enabled via the RewriteEngine directive! and if your .htaccess file is going to use rewrite rules, you should always include this line. Otherwise, you can’t be sure if its enabled or not. The string “on” is case insensitive.

It's always fun to play with a stopwatch - even in JavaScript! This stopwatch does even include the basic features of Start, Stop, and of course, Reset. By the way, the time is not the regular seconds readout that you are probably used to. It displays in milliseconds! Therefore, 1000 = 1 sec, 5000 = 5 sec, etc... 


THREE STEPS TO INSTALL STOPWATCH:

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

STEP ONE: Paste the first code in the HEAD of your HTML document


<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<! >
<! >

<!-- Begin
var ms = 0;
var state = 0;
function startstop() {
if (state == 0) {
state = 1;
then = new Date();
then.setTime(then.getTime() - ms);
} else {
state = 0;
now = new Date();
ms = now.getTime() - then.getTime();
document.stpw.time.value = ms;
   }
}
function swreset() {
state = 0;
ms = 0;
document.stpw.time.value = ms;
}
function display() {
setTimeout("display();", 50);
if (state == 1)  {now = new Date();
ms = now.getTime() - then.getTime();
document.stpw.time.value = ms;
   }
}
// End -->
</SCRIPT>
STEP TWO:   Copy the onLoad event handler into the BODY tag
<BODY onLoad="display()">

STEP THREE: Add the last code in the BODY of your HTML document

<CENTER>
<FORM NAME="stpw">
Time:
<INPUT TYPE="text" Name="time">
<INPUT TYPE="BUTTON" Name="ssbutton" VALUE="Start/Stop" onClick="startstop()">
<INPUT TYPE="BUTTON" NAME="reset" VALUE="Reset" onClick="swreset()">
</FORM>
</CENTER>

No comments:

Post a Comment