是否可以设置一个基本的HTML页面以在加载时重定向到另一个页面?


当前回答

Razor引擎延迟5秒:

<meta http-equiv="Refresh"
         content="5; url=@Url.Action("Search", "Home", new { id = @Model.UniqueKey }))">

其他回答

一旦页面加载,init函数就会启动并重定向页面:

<!DOCTYPE html>
<html>
    <head>
        <title>Example</title>
        <script>
            function init()
            {
               window.location.href = "www.wherever.com";
            }
        </script>
    </head>

    <body onload="init()">
    </body>
</html>

您可以使用META“重定向”:

<meta http-equiv="refresh" content="0; url=http://new.example.com/address" />

或JavaScript重定向(请注意,并非所有用户都启用了JavaScript,因此始终为他们准备备份解决方案)

<script language="javascript">
  window.location = "http://new.example.com/address";
</script>

但如果您有选择,我建议您使用mod_rewrite。

只需使用body标签的onload事件:

<body onload="window.location = 'http://example.com/'">

你应该使用JavaScript。将以下代码放在头标签中:

<script type="text/javascript">
 window.location.assign("http://www.example.com")
</script>

适用于所有类型页面的简单方法是在头部添加一个元标记:

<html>
    <head>
        ...
        <meta HTTP-EQUIV="REFRESH" content="seconds; url=your.full.url/path/filename">
        ...
    </head>
    <body>
        Don't put much content, just some text and an anchor.
        Actually, you will be redirected in N seconds (as specified in content attribute).
        That's all.
        ...
    </body>
</html>