0

Possible Duplicate:
How can you check for a #hash in a URL using JavaScript?

Im using the following to execute some JavaScript if the URL ends with a certain hash tag. How can I crete a similar conditional for if the URL doesnt end in a hash tag? Thanks

    if (window.location.href.match('#hash'))
    {
                //do stuff
    }
Community
  • 1
  • 1
Evanss
  • 23,390
  • 94
  • 282
  • 505

1 Answers1

4

https://developer.mozilla.org/en/DOM/window.location

if(window.location.hash) {
  //hash exists
} else {
  //no hash
}
Joseph
  • 117,725
  • 30
  • 181
  • 234