Hash retrieval from URL

103 Views Asked by At

I am trying to setup a form which grabs the hash from the url, then uses that value to determine what radio inputs to check. The latter part is working, but i cannot get the hash retrieval to work.

var url = document.referrer;
var dec= decodeURIComponent(url.replace(/\+/g, '%20'));
var hash = url.substring(url.indexOf('?')+1);
var hash = decodeURI(hash);

In firefox console, i try 'console.log(hash)', and simply get a Reference Error saying that 'hash is not defined'.

The entire script is here if needed - http://pastebin.com/Yq9NbHyz

1

There are 1 best solutions below

1
On

Because hash is not global variable. Use window.location.hash or location.hash