HTML metaタグでページを移動する

HTMLの<meta>タグを使うと、指定した時間後にページを移動させることができる。

次の<meta>タグは<head>タグの中に追加する。

<meta http-equiv="refresh" content="10;url=http://tistory.com">
<meta http-equiv="refresh" content="秒数;url=移動先url">

次の例は、10秒後に別のページへ移動する例である。

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="10;url=https://www.devkuma.com">
    <script src="https://code.jquery.com/jquery-latest.min.js"></script>
    <title>metaタグでページを移動する</title>
    <script>
     $(function() {
            var seconds = 10;
            function counting() {
	            $(".seconds").html(seconds--);
                setTimeout(counting, 1000);
            }
            counting();
     });
    </script>
</head>
<body>
    <h1>metaタグでページを移動する</h1>
    <p><span class="seconds">10</span>秒後にページが移動します。</p>
</body>
</html>

コード実行