【问题标题】:How to remove # from url and work without # with Javascript如何从 url 中删除 # 并在没有 # 的情况下使用 Javascript
【发布时间】:2021-04-08 02:13:44
【问题描述】:

我有用于带有锚的滑动页面的分页 jquery 并且工作得很好,但我想让它运行 whitout #page from the url ex: www.mysite.com/#aboutme

在此处查看插件:https://github.com/alvarotrigo/pagePiling.js

这是我目前所拥有的:

HTML:

<div class="collapse navbar-collapse sub-menu-bar" id="navbarSupportedContent">
   <ul class="navbar-nav m-auto">                        
     <li data-menuanchor="home" class="active"> <a href="">Home</a></li>
     <li data-menuanchor="aboutme"><a href="#despremine">About me</a></li>
   </ul>
</div> 

JS:

var myAnchors = [];
$( ".navbar-nav > li" ).each(function( index ) { myAnchors.push($(this).attr("data-menuanchor")); }); 

$('.fullpage-slider').pagepiling({
    scrollingSpeed: 280,
    navigation:false,
    menu: '.fullpage-progress-bar, .navbar-nav',
    sectionSelector: '.pp-scrollable',
    anchors: myAnchors,
    afterRender: function(anchorLink, index){ 
      NavbarColor(); 
    },
    afterLoad: function(anchorLink, index){ 
        $('.pp-scrollable .section-number').removeClass('show');
        $('.active .section-number').addClass('show');
        NavbarColor();
    } 

【问题讨论】:

    标签: javascript html jquery pagepiling.js


    【解决方案1】:

    pagePiling.js 网站上实际上有一个演示可以做到这一点: https://alvarotrigo.com/pagePiling/examples/noAnchor.html

    基本上,在初始化期间不要使用anchors 属性,你应该可以去:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-15
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 2010-11-26
      相关资源
      最近更新 更多