For example, I have a URL as :
http://www.google.com/#hash=value2x
I want a js code to return just value2x. I tried
value2x
function getHashValue(key) { var matches = location.hash.match(new RegExp(key+'=([^&]*)')); return matches ? matches[1] : null; } // usage var hash = getHashValue('hash');