*[javascript]10秒後に自動遷移 + カウントダウン表示

移転したサイトの旧URLにアクセスした時などによく見られる、
10秒後に自動遷移するページを javascript + JSP で作成しました。

遷移するまでの時間・遷移先URLをMETAタグ内で指定し、
カウントダウン表示をjavascriptで実装しています。

<%@ page language="java"
         pageEncoding = "Windows-31J"
         contentType="text/html; charset=Windows-31J" %>
<%
    // 遷移先URL
    String url = "http://www.yahoo.co.jp";

    // カウントダウン秒数指定(単位:秒)
    // 自動遷移までの秒数を変更したい場合は、この数値を変更してください。
    int timer = 10;
%>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;charset=Shift_JIS">
<meta http-equiv="refresh" content="<%= timer %>;URL=<%= url %>">
<script language="JavaScript">
<!--
    num = <%= timer %> + 1;
  
    function countdown(counter) {
        if (counter < 1){
	    return;
        }

        counter--;
        num = counter;

        document.getElementById("SET_COUNT").innerHTML = counter;
			
        // 1秒毎にカウントダウン処理を実行(単位:ミリ秒)
        setTimeout("countdown(num)",1000);
    }
-->
</script>
</head>

<body onLoad="countdown(num)" style="text-align:center">

<a href="<%= url %>"><%= url %></a><br><br>

<DIV id="SET_COUNT" style="position:absolute;"><%= timer %></DIV>&nbsp;&nbsp;&nbsp;秒後に自動的にジャンプします・・・<br>

<input type="button" value="とじる" onClick="window.close();"><br><br>

</body>
</html>