I have some jQuery/JavaScript code that I want to run only when there is a hash (#) anchor link in a URL. How can you check for this character using JavaScript?
#
function getHash() { if (window.location.hash) { var hash = window.location.hash.substring(1); if (hash.length === 0) { return false; } else { return hash; } } else { return false; } }