• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get window.location.hash to work in Fire Fox?

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm using window.location.hash to forward the user to a certain part of the HTML page. Works well in IE but not in Fire Fox (2.0.0.8).

I used the forum search but only found a post where no solution existed:
https://coderanch.com/t/116194/HTML-JavaScript/window-location-hash

Does anyone know a solution to this?

cheers,
Pete
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works fine in FF 2.0.0.8 for me. What exactly are you doing? Are there any messages in the Error Console?
 
Pete Neu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hm, just played around with problem and found out that IE has the peculiarity that it loads & executes this code when the page is loaded.

Firefox seems to refuse to do this and wants a tweaking like this:


I suppose this won't work any other way, right?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my test I didn't put the "#" in front of the hash name. Try if it works without it.

Firefox executes the code that you put directly into the script tag, but probably at a time when that hash mark doesn't exist, because the page hasn't been rendered yet.
[ October 22, 2007: Message edited by: Ulf Dittmer ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic