我想使用HTML将我的页面重定向到另一个页面但是当我尝试使用每个人都建议我的方法:<meta http-equiv="refresh" content="0; URL=http://zacharycabal.tumblr.com/tagged/b&w">
时,网页每10秒刷新一次,这会让它看起来很糟糕。
是否有可能使其重定向,然后再也不刷新?
答案 0 :(得分:1)
W3C使用元刷新is discouraged。因此建议使用服务器重定向。 JavaScript重定向可能无法在移动设备上运行,因为JavaScript可能会被禁用。我认为,如果可能,最好的方法是使用服务器重定向,因此在标头中发送301。这很容易通过.htaccess来完成。
此外,在某些情况下,浏览器可以忽略0值。我认为一个正确的方法可能是一个HTML刷新和一个JavaScript重定向。但使用服务器端当然更好:
<head>
...
<meta http-equiv="refresh" content="1;url=http://zacharycabal.tumblr.com/tagged/b&w">
<script language="javascript">
window.location.href = "http://zacharycabal.tumblr.com/tagged/b&w""
</script>
...
</head>
如果PHP是一个选项:
<?php
header("Location: http://zacharycabal.tumblr.com/tagged/b&w"", TRUE, 301);
exit;
?>
答案 1 :(得分:0)
如何在<body>
标记中加入一些Javascript:
<body onload="location.href = 'http://zacharycabal.tumblr.com/tagged/b&w';">
...
</body>
答案 2 :(得分:0)
试试这个:
<meta http-equiv="Refresh" content="10;url=http://www.pagenamehere.com">
您还可以在正文中包含页面重定向的邮件,以及链接以防万一。