Skip to content

"fixFirefoxAnchorBug" function in doctools.js causes navigating problem in Chrome #3549

@fireattack

Description

@fireattack

Problem

There is a function in doctools.js:

  fixFirefoxAnchorBug : function() {
    if (document.location.hash)
      window.setTimeout(function() {
        document.location.href += '';
      }, 10);
  }

This function was supposed to fix an anchor bug in Firefox. It used to have a condition of $.browser, so it will only be applied to Firefox; but now this function is removed in JQuery so it's removed here as well (#1709). Therefore, this function now applies to all the browsers. Unfortunately, it causes navigating problem in Chrome now, when you use back and forward.

The problem STR (Chrome only)

  1. Open a link with hash (anchor), e.g. https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
  2. Scroll away from the anchor position.
  3. Click any external link (means the link that is not an anchor of current page).
  4. Hit "back" button in the browser.

What happened:

When you navigating back, it doesn't go to your previous position. Instead, it goes to the anchor's location.

What it should do:

It should go to your previous position.

Ironically, it won't cause this problem in Firefox, despite it's supposed to be a fix for (a different) anchor bug in Firefox. Also, since Sphinx doc website is using the old theme, it doesn't have this problem either: try http://www.sphinx-doc.org/en/stable/tutorial.html#running-the-build and repeat the STR.

Comments

Please keep in mind the Firefox anchor bug we're talking about here will only happen if the anchor is assigned with <section id>: it doesn't have any bug if you merely want to jump to certain element with id, such as <div id="xxx">. From my observation we don't really use <section id>, so I don't even know if this function is really necessary to begin with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions