【问题标题】:url hide only domain name show in urlurl 仅隐藏在 url 中显示的域名
【发布时间】:2020-01-01 15:29:31
【问题描述】:

我的链接是www.example.com/#about 我想从 url 中隐藏 #about。 当我单击 about 时,我创建了一个 html 页面,然后滚动应该转到同一页面上的 about 部分。但 #about 显示在 url 中。我想隐藏#about#etc 我的页面工作相同,但在(#etc)之后隐藏 id 只想要 example.com 不想要www.example.com/#etc

【问题讨论】:

    标签: javascript php html .htaccess


    【解决方案1】:

    请找到我创建的fiddle 的链接。希望这会有所帮助:)

    JS 文件

    $(document).ready(function() {
      $('a').on("click", function(e) {
    
        var scrollTo = e.toElement.text
        console.log($(this).text())
        var posTop = $("#" + scrollTo).offset().top;
        console.log(posTop);
        e.preventDefault();
        e.stopPropagation();
        $('html, body').scrollTop(posTop);
        console.log(window.location);
    
      });
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-08
      • 2011-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 2015-12-21
      • 1970-01-01
      相关资源
      最近更新 更多