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

Simple use of location hash:

if(window.location.hash) {
  // Fragment exists
} else {
  // Fragment doesn't exist
}

Leave a Comment