14

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>

両方の方法の結果として、私はサイクリングページを更新しました。

この問題を正しく解決する方法は?

4

1 に答える 1

9

ページをリダイレクトする必要はありません。を設定するだけwindow.location.hashです。

window.location.hash="anchor";
于 2012-08-31T13:00:20.340 に答える