【发布时间】:2019-09-09 19:36:12
【问题描述】:
我想要做的是运行一个动画 7 秒然后重定向到实际的 index.html 文件,但是当我使用下面的代码时,动画在 7 秒内完成它重定向到 index.html 然后它不断重新加载索引.html。我正在考虑使用 for 循环或 if 语句,但我真的不知道从哪里开始。
$(function() {
setTimeout(function() {
$(".fly-in-text").removeClass("hidden");
});
setTimeout(function() {
$(".allblack").remove();
}, 7000);
$(document).ready(function() {
// Handler for .ready() called.
window.setTimeout(function() {
location.href = "index.html";
}, 7000);
});
});
【问题讨论】:
-
请不要发布代码图片。更多信息请查看meta.stackoverflow.com/q/285551。
-
我建议检查
location.href不是index.html,然后才加载索引。否则你已经在 index.html 中,不需要重新加载 -
我已经为它尝试了一个 if 语句,然后它会每 1 秒刷新一次页面。
标签: javascript function if-statement event-handling dom-events