http://www.domainname.com/#changepassword
I need to pass an extra variable with a URL like above.
I’ve tried a few ways but I’m unsure of the best way to do this eg:
http://www.domainname.com/#changepassword?variable
I’m using the following JQUERY to catch the HASH:
if (window.location.hash != '') {
var hash = window.location.hash.substring(1);
if(hash == 'changepassword') { // Password Change
alert('changepassword');
}
}
How can I pass an extra variable with the HASH? Best method to capture the HASH and extra variable.
thx
You are mixing the
location.hashwithlocation.search– see here for the explanationYou could use just the
location.hashand put a seperator between your “variables” :For example .. if this was your url
http://www.domainname.com/#changepassword-variable-anotherthen you could door you could use the
location.searchand the following example :URL :
http://www.domainname.com/?command=changepassword&var=variable&var2=anotherthis uses the
key=valueformat, then use the following method to access thevaluesYou can then get the values by passing the function your
key