<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> part of the Window object </title>
<script type= "Text/javascript" >
Timing in an infinite loop
var c = 0;
var T;
function Timecount () {
document.getElementById ("TXT"). Value = C;
c = c+1;
t = setTimeout ("Timecount ()", 1000);
}
Timing in an infinite loop-with a stop button
var c = 0;
var T1;
function Begaincount () {
document.getElementById (' Txt1 '). Value=c
C1=c1+1
T1=settimeout ("Begaincount ()", 1000)
}
function Stopcount () {
Cleartimeout (t1);
}
A clock
function StartTime () {
var today = new Date ();
var h = today.gethours ();
var m = today.getminutes ();
var s = today.getseconds ();
m = Checktime (m);
s = checktime (s);
document.getElementById ("Txt2"). InnerHTML = H + ":" + M + ":" + S;
t = setTimeout (' StartTime () ', 500);
}
function Checktime (i) {
if (i<10) {
i = "0" + i;
}
return i;
}
Show pop-up
function Show_popup () {
var p = window.createpopup ();
var pbody = p.document.body;
Pbody.style.backgroundcolor= "Red"
Pbody.style.border= "Solid black 1px"
Pbody.innerhtml= "This is a pop-up! Click outside the pop-up to close it! "
P.show (150,150,200,50,document.body)
}
document.getElementById ("P1"). Innerhtml= "New text!";
</script>
<body onload= "StartTime ()" >
<!--in the infinite loop---
<form>
<input type= "button" value= "Start timing! "Onclick=" Timecount () ">
<input type= "text" id = "TXT" >
</form>
<p> Click on the button above and the chronograph will be timed from 0 onwards. </p>
<!--the timing in an infinite loop-with a stop button--
<form>
<input type= "button" onclick= "Begaincount ()" value= "Start timing" >
<input type= "text" id = "TXT1" >
<input type= "button" onclick= "Stopcount ()" value= "Stop Timing" >
</form>
<p> Click on the "Start timing" button above. The input box will be timed from 0 onwards. Tap stop timing to stop the timing. </p>
<!--one clock--
<div id = "TXT2" ></div>
<!--show Pop-up-->
<input type= "button" onclick= "Show_popup ()" value= "show_pop-up" >
</body>
2015/12/23--Partial Window Object