为了账号安全,请及时绑定邮箱和手机立即绑定

重定向到站点并跳转到锚点

重定向到站点并跳转到锚点

慕森王 2021-12-02 19:51:46
我尝试重定向到一个站点并跳转到该站点上的锚点。锚是 #tab-5我试过:window.location.href = "/property/details?id=123#tab-5";和window.location.replace("/property/details?id=123#tab-5");我还尝试使用包含域名的完整 URL。但该网站不会重新加载。URL 只是被替换,它不会跳转到锚点。.htaccess<IfModule mod_rewrite.c>    RewriteEngine On    # Send would-be 404 requests to Craft    RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]    RewriteRule (.+) index.php?p=$1 [QSA,L]</IfModule>索引.php<?phpob_start();session_name("xxx");session_start();include("app/Routes.php");$template = checkRoute();// Redirect to login page if user is not logged inif (!$template && !isset($_SESSION["logged_in"])) {    $bodyClass = "login";    $template = "templates/php/login.php";// Redirect to start page (list view) if user is logged in and no url is given} else if (!$template) {    header("Location: /property/list");    exit;}// Redirect to templateif (file_exists($template)) {    require_once($_SERVER["DOCUMENT_ROOT"] . "/master.php");    exit;}应用程序/Routes.php<?php/** * A .htaccess rule always calls the index.php if a file could not be found. * This method gets called by index.php and creates a path out of the request * url path and returns the affiliated template file if exist. If nothing is found, * then return "no-route" template. */function checkRoute(){    $redirectUrl = (isset($_SERVER["REDIRECT_URL"])) ? $_SERVER["REDIRECT_URL"] : "";    $_SERVER["REDIRECT_URL"] = "";    if (!empty($redirectUrl) && $redirectUrl !== "/login") {        $templateRoot = "templates";        $template = $templateRoot . "/php". $redirectUrl .".php";    }}
查看完整描述

1 回答

?
凤凰求蛊

TA贡献1825条经验 获得超4个赞

我通过window.location.reload()在它之后调用解决了它


查看完整回答
反对 回复 2021-12-02
  • 1 回答
  • 0 关注
  • 189 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信