152.63 KB, text/html
152.62 KB, text/html
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0 Build ID: 20130104151925 Steps to reproduce: Having an input box with autofocus in the beginning of the pages, and then having an anchor(s) later in the page. Actual results: Linking to an anchor inside the page from an external page would fail to jump to the anchor. Clicking again after the page loads will jump to the anchor. Expected results: The browser should jump to the anchor even if the autofocus exists. IE and Chrome does the right behavior. Removing the autofocus gets firefox to jump to the anchor directly.
Please, attach a minimal testcase (online if you want), so we could test.
Dupe for Bug 668213 (which proposed to dupe with bug 633821)?
Component: Untriaged → Document Navigation
Product: Firefox → Core
Created attachment 714072 [details] Test case where autofocus for the input box will override the anchors.
Created attachment 714074 [details] Test case where autofocus was removed from the input box. Now anchors work. Try to reach an example anchor #Q using this file and using the other file with autofocus. The first time to reach this anchor will fail if there is an autofocus, if you try AGAIN while the page is LOADED. The browser will jump.
Works for me with 2013-02-14-03-28-50-mozilla-central-firefox-21.0a1.en-US.linux-x86_64 firefox-18.0.1.ru.linux64
Keywords: testcase-wanted → testcase
I can confirm the behavior in Firefox 34.0 (Mac OS X 10.8.5) and Firefox Nightly 37.0a1 (2014-12-20). My test is available at http://medialize.github.io/ally.js/tests/browser-bugs/blink-autofocus.html#foo I can also add that Blink (not WebKit) has the same issue: https://code.google.com/p/chromium/issues/detail?id=382901
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: x86 → All
Version: 18 Branch → Trunk
When both, autofocus and fragment-anchor are present, the following event sequence is played: init (synchronous script at end of document) target: null activeElement: BODY focus event event.target: #document focus event event.target: INPUT readystatechange event readyState: interactive target: null activeElement: INPUT DOMContentLoaded target: DIV activeElement: INPUT readystatechange event radyState: complete target: DIV activeElement: INPUT load event target: DIV activeElement: INPUT The fragment's target (`:target`) is only accessible after DOMContentLoaded, the autofocus element receives focus *before* the document enters interactive state. Disabling the autofocus by adding the following script to the end of the document has will cause the <input> to not have that attribute anymore, but is still focused right away: <script>document.querySelector('[autofocus]').removeAttribute('autofocus');</script> There is no way to *prevent* the <input> from receiving focus, you can only blur it, and move the document back to the :target (using Element.scrollIntoView ) after the fact.  https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollIntoView
> Disabling the autofocus by adding the following script to the end of the document has will > cause the <input> to not have that attribute anymore, but is still focused right away: > <script>document.querySelector('[autofocus]').removeAttribute('autofocus');</script> While that holds true, removing the [autofocus] element will, of course, issue a blur event, making <body> the activeElement and fragment target remains in the viewport. After pressing <kbd>Command R</kbd> to reload the document, scroll position moves to the beginning, as if the [autofocus] element was moved into viewport. This does not happen with <kbd>Command Shift R</kbd>.
You need to log in before you can comment on or make changes to this bug.