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


当前回答

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

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

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

其他回答

我还将添加一个规范链接来帮助您的SEO人员:

<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish"/>

最好设置301重定向。请参阅谷歌网站管理员工具文章301重定向。

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

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

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

Razor引擎延迟5秒:

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

位于头部内部的以下元标记将告诉浏览器重定向:

<meta http-equiv="Refresh" content="seconds; url=URL"> 

将秒替换为重定向前等待的秒数,并将URL替换为要重定向到的URL。

或者,您可以使用JavaScript重定向。将其放置在页面上的任意位置的脚本标记中:

window.location = "URL"