Bug 22599 - Setting window.location.hash to "#id_some_div" does not set focus to that div.
Summary: Setting window.location.hash to "#id_some_div" does not set focus to that div.
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-02 13:28 PST by ivan
Modified: 2015-08-18 17:33 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ivan 2008-12-02 13:28:03 PST
Setting window.location.hash with javascript does nothing when set to the id of a div in the current document (e.g. window.location.hash='#div_id';).  It should set focus to the target div and allow keyboard scrolling of the content.  It also doesn't work when #id is assigned to window.location.href or just window.location.  All of these variants work perfectly with Firefox (and even IE7) but not with Safari or Google Chrome (which is why I perceive the problem to be in Webkit itself).

Interestingly, an html link, <a href="#id_some_div"> does work correctly, but I need to use javascript (in strict html, I'm simulating an iFrame by hiding and unhiding div's within a containing, positioned div and then re-locating to the newly unhidden div by setting window.location).

I am well aware the location object is not standardized, but this is an important cross browser issue, because what I'm doing is fairly widespread with Firefox and IE, together the majority of end users.

FYI, I'm seeing this with Safari 3.2.1 (525.27.1).

I'd give a link, but it's on an Intranet.  If you really need one, I can put a page outside the firewall.
Comment 1 James Craig 2015-08-18 01:11:26 PDT
Please include a link to the part of the HTML spec that defines this as expected behavior.
Comment 2 Chris Rebert 2015-08-18 17:33:53 PDT
I can't reproduce.
The focusing works fine in Safari 8.0.8 AFAICT.
Testcase: http://jsfiddle.net/cvrebert/8z9xyo1z/