Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Hash not working in Chrome

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #169099

    I have a list of people and wanted to implement a feature that would automatically scroll to a person.

    All the persons have unique IDs so I figured out I could just use hashes to make it work.

    My problem now is that if I pass the url “http://example.com/site#person” into the omnibox in Chrome will, once I hit enter, change the url to “http://example.com/site”. After that I can manually reenter the hash and it works.

    This behavior seems rather odd and prevents me from using it as an easy way to scroll.

    If any of you know a workaround or have experienced similar problems, I would be glad if you shared.

    Thank you in advance.

    #169103
    __
    Participant

    I’m using Chrome, and I don’t see this behavior: works as expected for me. Can you provide a test case that demonstrates the problem?

    #169144

    I found the problem, it conflicted with a history.pushState function and I was able to fix it by simply adding +location.hash to it. Though this seems kind of hacky to me since this function is only executed after the document is loaded and does not alter the HTML of the page. Nevertheless thank you for your reply!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.