This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: "fixFirefoxAnchorBug" function in doctools.js causes navigating problem in Py3 doc in Chrome
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Mariatta, berker.peksag, docs@python, fireattack
Priority: normal Keywords:

Created on 2017-10-03 04:35 by fireattack, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg303576 - (view) Author: fireattack (fireattack) * Date: 2017-10-03 04:35

This is a regression bug/flaw in Sphinx's doctools.js, a JS file used in its base template, and therefore got inherited to Python 3's documentation website. Python 2's documentation website is not affected because it's based on an older version of Sphinx.

There is a function in doctools.js:

* workaround a firefox stupidity
* see:
fixFirefoxAnchorBug : function() {
if (document.location.hash)
window.setTimeout(function() {
document.location.href += '';
}, 10);

This function was supposed to fix an anchor bug in Firefox (see comment). It *used to* have a condition of $.browser outside, so it will only be applied to Firefox; but it was removed in JQuery so it was removed here as well. 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.
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.


I reported it to Sphinx as well: but didn't get any response so far.

Please keep in mind the Firefox anchor bug mentioned above will only happen if the anchor is assigned with <section id>. From my observation we don't really use <section> in HTML, so I don't think this workaround function is really necessary here to begin with.
msg303629 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-10-03 16:39
Is there anything to be done in CPython? It appears to be either a bug with the browser or Sphinx...
msg303631 - (view) Author: fireattack (fireattack) * Date: 2017-10-03 16:50
Well, since it affects Python's site's functionality, I thought it's appropriate to report here (with components: documentation). I followed the instruction here:

It is not Sphinx's bug per se, since it has nothing to do with its software; just an ancient problematic script in template got copied here. 

It is not a Chrome bug, since that script was not intended to apply to Chrome to begin with.

But anyway, if anyone found it's not the right place, feel free to close it.
msg305555 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-04 11:17
This is indeed an annoying bug. Turns out there is already a compatibility shim for $.browser in doctools.js:

I've opened to add the "$.browser.firefox" check back.

There is nothing we can do here because we don't maintain a copy of doctools.js in Python codebase:

    $ git ls-files | grep doctools.js

Thank you for your report.
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75849
2017-11-04 11:17:18berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg305555

resolution: third party
stage: resolved
2017-10-03 16:50:51fireattacksetmessages: + msg303631
2017-10-03 16:39:56Mariattasetnosy: + Mariatta
messages: + msg303629
2017-10-03 04:35:20fireattackcreate