2016-10-16 10 views
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> 
+1

はheader()には必要ありませんphp function in javascript。 setTimeout関数の 'window.location.href =" TV_moem_ruki.php ";'を使用してください –

+0

ありがとうございます。これは働いた。 – user72160

答えて

0

あなたは2ページ目に(ほんの数秒間開いたままになります1)このコードを貼り付けて、いくつかの方法、それを行うことができます。

<meta http-equiv="refresh" content="{numberOfSeconds}; url='TV_moem_ruki.php'" /> 

やJavaScriptでの

window.setTimeout(function() { 
    window.location.href = 'TV_moem_ruki.php' 
}, numberOfSeconds * 1000) 

これは、TV_moem_ruki.phpが最初のページであることを前提としています。

関連する問題