【問題】倒數 10 秒 語法



贊助商連結


bloom
2006-05-30, 03:22 PM
<META HTTP-EQUIV="refresh" CONTENT="10; URL=http://xxx.xxx.xxx.xxx">
可以 10 秒導向另一個網址

如果要在網頁上秀出 10 9 8 7 6 5 4 3 2 1 的倒數語法,要如何製作
謝謝 ^_^

贊助商連結


twpollo
2006-06-02, 02:06 PM
請混合使用 javascript 與 HTML DOM.

動態式client side = javascript + HTML DOM
動態式server side = PHP, etc

twpollo
2006-06-03, 12:53 PM
<html>
<head>
<script type="text/javascript">
var t
function timedCount(){

document.getElementById('txt').value -= 1
if( document.getElementById('txt').value > 0)
t=setTimeout("timedCount()",1000)
if( document.getElementById('txt').value == 0)
window.open('你的url','_self');
}
</script>
</head>

<body onload="timedCount()">
<input type="text" id="txt" value="11">
</body>

</html>

twpollo
2006-06-03, 02:15 PM
只要copy這個到 .html 就可以了
PS: 這是剛剛一點空閒的時候寫的~
所以有些可縮短和改進的地方~
但重點是 100%可用 ... ( ^_^) /

twpollo
2006-06-03, 02:20 PM
補充:
要 20sec的話就把
<input type="text" id="txt" value="11">
改為
<input type="text" id="txt" value="21">
還有要導向另一個網址如 http://xxx.xxx.xxx.xx/就是把
window.open('你的url','_self');
改成
window.open('http://xxx.xxx.xxx.xx/','_self');

就這樣 ^^

bloom
2006-06-05, 03:54 PM
謝謝您,可以 ^_^