Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #12227
Closed
Open
Issue created Jan 15, 2014 by Administrator@rootContributor

scrollspy can't handle href attributes that don't start with #

Created by: mindw0rm

Scrollspy won't work if the href attributes in the assigned target start with the current URI (e.g. href="/path/to/some.html#some-id").

This can be fixed by small changes in Scrollspy.prototype.refresh and Scrollspy.prototype.active:

 ScrollSpy.prototype.refresh = function () {
   [...]
        var href = $el.data('target') || $el.attr('href')
        /*fix part 1 (line 52 in v3.0.3): remove URI prefix if present */
        if (href[0] != '#') href = '#'+href.split('#')[1] 
        /***/
        var $href = /^#./.test(href) && $(href)
    [...]
  }
  ScrollSpy.prototype.activate = function (target) {
    [...]
    var selector = this.selector +
        '[data-target="' + target + '"],' +
        /* fix part 2 (line 101 in v3.0.3): use href$= instead of href= */
        this.selector + '[href$="' + target + '"]'
    [...]
  }```
Assignee
Assign to
Time tracking