【问题标题】:redirect to same page to anchor [duplicate]重定向到同一页面以锚定[重复]
【发布时间】:2012-08-26 06:59:15
【问题描述】:

需要将http://sitename.com/cat/index.php重定向到http://sitename.com/cat/index.php#anchor

我尝试了 2 种方法:php 重定向和元刷新

PHP 重定向

<?php
    $URL = "http://sitename.com/cat/index.php#anchor";
    header("Location: $URL");
?>
<html>
....

元刷新

<html>
    <head>
    ... 
    <meta http-equiv="refresh" content="0;url=http://sitename.ru/cat/index.php#anchor">
    ...
    </head>
...
</html>

结果我有循环页面刷新。

如何正确解决这个问题?

【问题讨论】:

标签: php redirect


【解决方案1】:

您不需要重定向页面,只需设置window.location.hash

window.location.hash="anchor";

【讨论】:

  • 这是我的问题的真实方式。谢谢你。
  • @xdazz 不使用javascript可以解决这个问题吗?
猜你喜欢
  • 2013-12-28
  • 1970-01-01
  • 2023-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-11
  • 2011-11-06
  • 2017-09-09
相关资源
最近更新 更多