0
不知道什麼是錯誤的代碼,因爲按鈕r不移動和計時器不工作。按鈕和時間不工作
由於按鈕在60秒之前很難捕捉,因爲它應該移動整個屏幕。
我試着用代碼,但按鈕只移動一次。當我將鼠標箭頭放在它上面時,我希望按鈕始終移開。
<SCRIPT>
var lose = 'YOU LOST'
var win = 'YOU WON'
function finish(message) {
clearTimeout(timer)
output.innerHTML = message
button1.style.display='none'
button2.style.display='none'
button3.style.display='none'
}
function moveme(obj) {
obj.style.pixelLeft += Math.random() * 250 - 150
obj.style.pixelTop += Math.random() * 250 - 150
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="goldenred" TEXT="black" onSelectStart="return false">
<CENTER>
<H1><b>Test</b></H1>
<P>If you can't click this button, you r lost!<BR>You got 60 sec.!</P>
<BR><BR>
<INPUT
TYPE=BUTTON
ID=button1
onClick="finish(win)"
onMouseOver="this.style.position='absolute'; moveme(this)"
VALUE="CLICK"
STYLE="display:none; top:300; left:200"
>
<INPUT
TYPE=BUTTON
ID=button2
onClick="finish(win)"
onMouseOver="button1.style.display=''; button3.style.display=''; this.style.position='absolute'; moveme(this); timer = setTimeout('finish(lose)', 60000)"
VALUE="CLICK"
STYLE="top:300; left:200"
>
<INPUT
TYPE=BUTTON
ID=button3
onClick="finish(win)"
onMouseOver="this.style.position='absolute'; moveme(this)"
VALUE="CLICK"
STYLE="display:none; top:300; left:200"
>
<SPAN ID="output"></SPAN>
我完成更改時間爲60000ms。輸出是消息,因爲我不想讓任何人觸摸按鈕... – user2713675