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
    }
2
  • Similar but none of them answer it exactly. The first answer is almost there but uses an if and else not just an else. Commented Mar 21, 2012 at 11:53
  • if(!window.location.hash) { ... Commented Mar 21, 2012 at 11:54

1 Answer 1

4

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

if(window.location.hash) {
  //hash exists
} else {
  //no hash
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.