gpt4 book ai didi

ruby - 在 rails 3.1 中几秒钟后重定向

转载 作者:数据小太阳 更新时间:2023-10-29 07:29:12 27 4
gpt4 key购买 nike

有没有办法只使用 rails 在几秒后重定向?

我希望当用户单击链接时看到该页面并在几秒钟后重定向到他的个人资料(user_path)

最佳答案

因为 HTML 是 Rails 应用程序的一部分,您可以默认使用标准的 html 重定向选项:

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html">

0 更改为您希望在重定向前等待的秒数。

另一方面,您可以使用 javascript(也是 rails 应用程序的一部分):

<html>
<head>
<script type="text/javascript">
function delayedRedirect(){
window.location = "/default.aspx"
}
</script>
</head>
<body onLoad="setTimeout('delayedRedirect()', 3000)">
<h2>You'll be redirected soon!</h2>
</body>
</html>

关于ruby - 在 rails 3.1 中几秒钟后重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9206896/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com