我看到下面的页面上未经授权使用401个重定向轨道4,5:重定向状态:401挂在“您正在重定向。”我如何强制重定向?
我很好此页面的渲染,但不与网页挂确定。
带锚文本“重定向”的链接可以在重定向到正确的页面时正常工作,但必须单击该链接。换句话说,该消息是不正确的,我没有被主动重定向。
如何强制重定向?
这里是可以实现这一目的的代码,在action_controller/metal
def redirect_to(options = {}, response_status = {}) #:doc:
raise ActionControllerError.new("Cannot redirect to nil!") unless options
raise AbstractController::DoubleRenderError if response_body
self.status = _extract_redirect_to_status(options, response_status)
self.location = _compute_redirect_to_location(request, options)
self.response_body = "<html><body>You are being <a href=\"#{ERB::Util.unwrapped_html_escape(location)}\">redirected</a>.</body></html>"
end
使用JavaScript与setTimeout – Leon
好主意,但我怎么让js到ru n在布局中:仅用于此视图的false环境 – Abram
将其添加到视图本身并使用vanilla JS作为jquery可能未加载。 – Leon