需要从http://sitename.com/cat/index.php重定向到http://sitename.com/cat/index.php#anchor
我尝试了两种方法:php重定向和元刷新
PHP重定向
<?php
$URL = "http://sitename.com/cat/index.php#anchor";
header("Location: $URL");
?>
<html>
....
Run Code Online (Sandbox Code Playgroud)
元刷新
<html>
<head>
...
<meta http-equiv="refresh" content="0;url=http://sitename.ru/cat/index.php#anchor">
...
</head>
...
</html>
Run Code Online (Sandbox Code Playgroud)
结果两种方式我都有自行车页面刷新.
如何正确解决这个问题?
您无需重定向页面,只需设置window.location.hash.
window.location.hash="anchor";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2505 次 |
| 最近记录: |