• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 43027
76
  • 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: 43027
76
  • 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