This question already has answers here:
How do I redirect to another webpage?
(58个答案)
7年前关闭。
我应一个 friend 的要求创建了一个随机站点,询问该问题是什么(答案(互联网上的一个玩笑)是“他有赃物吗?”)给出密码并根据对与错来写入文档,但是我希望它能够满足赃物的条件,将其重定向(延迟5秒后)到Tumblr,这是个很棒的网站。
到目前为止,这是我的代码:)
提前非常感谢您!
(58个答案)
7年前关闭。
我应一个 friend 的要求创建了一个随机站点,询问该问题是什么(答案(互联网上的一个玩笑)是“他有赃物吗?”)给出密码并根据对与错来写入文档,但是我希望它能够满足赃物的条件,将其重定向(延迟5秒后)到Tumblr,这是个很棒的网站。
到目前为止,这是我的代码:)
<!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>
提前非常感谢您!
最佳答案
将此代码插入您的成功条件。
setTimeout(function(){window.location.href="tumblr.com"},5000);
关于javascript - 如果满足if语句,如何在延迟后重定向,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16862649/
10-11 13:17