我找到了这个答案:
这基本上可以满足我的需要。但不是让它在最后重定向到另一个页面,我希望它只是不断地循环浏览短信。显然,我删除了 IF 部分以停止重定向,但是如何让它反复循环浏览短信?
function nextMsg() {
if (messages.length == 0) {
// once there is no more message, do whatever you want
alert("redirecting");
} else {
// change content of message, fade in, wait, fade out and
// continue with next message
$('#message').html(messages.pop()).fadeIn(500).delay(1000)
.fadeOut(500, nextMsg);
}
};
// list of messages to display var messages = [
// "Hello!",
// "This is a website!",
// "You are now going to be redirected.",
// "Are you ready?",
// "You're now being redirected..."
// ].reverse();
// initially hide the message $('#message').hide();
// start animation nextMsg();