0
html/php頁面需要重定向到另一個html/php頁面,該頁面應該保持打開一段時間。然後,它需要恢復到原來的狀態。在特定時間重定向頁面
<meta http-equiv="refresh" content="1;URL='TV_moem_ruki.php'" />
在頁面加載後立即重定向。
我已經試過這
header("Location: TV_moem_ruki.php") ;
結合到下面的腳本,它在某些時間點刷新頁面,但它不工作。
<script>
refreshAt(13,10,0); //Will refresh the page at 11:05am
</script>
<script>
function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();
if(now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setHours(hours);
then.setMinutes(minutes);
then.setSeconds(seconds);
var timeout = (then.getTime() - now.getTime());
setTimeout(function() { window.location.reload(true); }, timeout);
header("Location: TV_moem_ruki.php") ;
}
</script>
header()php函數不需要JavaScript。只需使用'window.location.href =「TV_moem_ruki.php」;'在setTimeout函數中 –
謝謝。這一個工作。 – user72160