可打听时间的按钮.txt

来自「JavaScript特效(新)这里有许多的JAVA特效.供学者参考」· 文本 代码 · 共 51 行

TXT
51
字号
<html>
<head>
<TITLE>buttons clocks</TITLE>

<script language=javaScript>
<!-- Beginning of JavaScript -

var showtime=true
var timer
var i_sec=0

function clockon() {
    if (i_sec < 5) {
	    thistime= new Date()
	    var hours=thistime.getHours()
	    var minutes=thistime.getMinutes()
	    var seconds=thistime.getSeconds()
	    if (eval(hours) <10) {hours="0"+hours}
	    if (eval(minutes) < 10) {minutes="0"+minutes}
	    if (seconds < 10) {seconds="0"+seconds}
	    thistime = hours+":"+minutes+":"+seconds
	    document.forms[0].elements[0].value=thistime
        i_sec++
	    timer=setTimeout("clockon()",1000)
    }
    else {
        clearTimeout(timer)
        i_sec=0
        document.forms[0].elements[0].value="现在几点?"
    }
}

function clockoff() {
	clearTimeout(timer)
    document.forms[0].elements[0].value="现在几点?"
}

//-->
</script>

</head>

<body obgcolor="#FFFFFF">
<form>
<input type="button" value="现在几点?" onClick="clockon()" onMouseOver="clockon()" onMouseOut="clockoff()">
</form>
</body>
</html>


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?