HTMLではできません301ジャンプはい、でも通すことは可能です
5秒後、同じディレクトリ内のhello.htmlファイルに自動的にジャンプします(ご自身のニーズに合わせて変更してください)。
以下は詳細を示すための5つの例です。これらの例の主な機能は、5秒後に同じディレクトリ内の自動的にhello.htmlファイル(自分のニーズに応じて変更)ファイルにジャンプすることです。
1) HTML実装 <head> <!-- 次の方法は他のページにジャンプせずにリフレッシュするだけです --> <meta http-equiv="refresh" content="10"> <!-- 定期的に他のページに行> <meta http-equiv="refresh" content="5;url=hello.html"> </head>
メリット:シンプル 短所:ストラッツタイルでは利用できません 2) JavaScriptの実装 <スクリプト言語="javascript" タイプ="text/javascript"> 次の方法は直接ジャンプします window.location.href='hello.html'; 以下は通常のジャンプです setTimeout("javascript:location.href='hello.html'", 5000); </script>
長所:柔軟性があり、他の機能を組み合わせることができます 短所:異なるブラウザによる影響
3) 逆カウントダウン(IE)を用いたJavaScript実装 <スクリプト言語="javascript" タイプ="text/javascript"> var second = document.getElementByIdx_x('totalSecond').textContent; setInterval("redirect()", 1000); 関数 redirect()
{ document.getElementByIdx_x('totalSecond').textContent = --second; もし(2< 0)location.href = 'hello.html' の場合;
} </script>
メリット:より使いやすくなります 欠点:Firefoxは対応していません(spanやdivなどのinnerText属性をサポートしません)
3')は、相互JavaScript実装(Firefox)を組み込んでいます。 <span id="totalSecond">5</span> <スクリプト言語="javascript" タイプ="text/javascript"> var second = totalSecond.innerText; setInterval("redirect()", 1000); function redirect(){ totalSecond.innerText=--second; if(second<0) location.href='hello.html';
} </script>
4) FirefoxがinnerTextをサポートしていない問題を修正する <span id="totalSecond">5</span> <スクリプト言語="javascript" タイプ="text/javascript"> if(navigator.appName.indexOf("Explorer") > -1){ document.getElementByIdx_x('totalSecond').innerText = "my text innerText"; } else{ document.getElementByIdx_x('totalSecond').textContent = "my text textContent";
} </script>
5) 積分 3) および 3')
<span id="totalSecond">5</span>
<スクリプト言語="javascript" タイプ="text/javascript"> var second = document.getElementByIdx_x('totalSecond').textContent;
if (navigator.appName.indexOf("Explorer") > -1) { second = document.getElementByIdx_x('totalSecond').innerText; } そうでなければ { second = document.getElementByIdx_x('totalSecond').textContent;
}
setInterval("redirect()", 1000); function redirect() { もし(秒<0){ location.href = 'hello.html'; } そうでなければ { if (navigator.appName.indexOf("Explorer") > -1) { document.getElementByIdx_x('totalSecond').innerText = second--; } そうでなければ { document.getElementByIdx_x('totalSecond').textContent = second--; }
}
} </script>
|