How to detect the #hash and get the hash in JavaScript?

How to detect the #hash and get the hash in JavaScript? It’s better if no additional library is needed. That said, jquery is fine if it is needed.

You can use this piece of JavaScript code:

if (window.location.hash) {
    // hash found
    var hash = window.location.hash.substring(1);
} else {
    // No hash
}

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *