كود ساعة في زر
الكود:
<body onLoad="start()" bgcolor="White" text="Black" link="Blue" vlink="Blue" alink="Blue">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
var t = null;
var running = false;
function start(){
stop();
setValue();
}
function stop(){
if(running)
clearTimeout(t);
running = false;
}
function setValue(){
var now = new Date();
hours = ((now.getHours()<10) ? "0" : "") + now.getHours();
mins = ((now.getMinutes()<10) ? "0" : "") + now.getMinutes();
secs = ((now.getSeconds()<10) ? "0" : "") + now.getSeconds();
document.clock.face.value = hours+":"+mins+":"+secs;
t = setTimeout("setValue()",500);
}
//-->
</SCRIPT>
<FORM NAME="clock">
<INPUT TYPE=BUTTON NAME="face" VALUE="00:00:00">
</FORM>