2013-05-31 13 views
6

私の友人の要求によって、質問が何であるかを質問するとランダムなサイトのものが作成されました(回答(インターネット冗談)私はそれが正解か間違っているかによって、与えられたパスコードをチェックして文書に書いてもらうことにしました。しかし、私はそれを望みます。 Tumblrの、素晴らしのサイト。if文が実行された場合に遅れてリダイレクトする方法

から5秒の遅延が)これは、これまでの私のコードです:)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
    <head> 
     <title>The ultimate question</title> 
     <style> 
    body{ 
    background-color:rgb(238, 235, 229); 
    } 
    #scriptresult{ 
    font-family:calibri; 
    font-size:26px; 
    width:30%; 
    margin-left:35%; 
    text-align:center; 
    margin-top:15%; 
    border-color:rgb(91, 122, 221); 
    border-style:solid; 
    border-width:5px; 
    padding:20px; 
    background-color:rgb(240, 219, 200);  
    } 

    </style> 
    </head> 
    <body> 
    <div id="scriptresult"> 


<script language="Javascript"> 
var passcode; 
passcode = prompt("What is the ultimate question? (Make sure to include the ? at the end)"); 
passcode = (passcode.toUpperCase()); 
document.write("Your guess was" + " " + passcode); 
if (passcode == "DO HE GOT A BOOTY?" || passcode == "DO HE GOT THE BOOTY?" || passcode == "DO HE GOT DA BOOTY?") { 
    document.write("<br>Congratulations! You got da answer! Visit the awesomness!"); 
    else if (passcode == "DOCTOR WHO?" || passcode == "WHAT IS THE MEANING OF LIFE?" || passcode == "WHAT IS THE DOCTORS NAME?" || passcode == "WHAT IS THE DOCTOR'S NAME?") { 
     document.write("<br>Not quite... But I love the guess! Think along the line of booty...<br><h6>(Hit refresh to try again)</h6>"); 
    } else { 
     document.write("<br>Nope. That's wrong.<br><h6>(Hit refresh to try again)</h6>"); 
    } 
</script> 
</div> 
</body> 
</html> 

は、事前にどうもありがとうございます!

答えて

1

あなたの成功条件にこのコードを挿入します。

setTimeout(function(){window.location.href="tumblr.com"},5000); 
+0

ありがとうございました!それはすごくうまくいった!私はあなたを投票するだろうが、私は評判が必要...しかし、ええ..ありがとう:) –

0

これにより、5秒後に関数を実行できます。あなたの通過で

setTimeout(function() { 
    // Do redirect here... 
}, 5000); 
0

if文:

window.setTimeout(function() { 
    location.href = "www.tumblr.com"; //is this the right link? 
}, 5000); 
+0

私はちょうどhttp://をそれに追加しなければならず、それは驚異的に機能しました!ありがとう:) –

関連する問題