/ Published in: JavaScript
(I did not write this, but I forgot where I got it.)
This code will find all the variables passed though the URL and return the one you are looking for.
Expand |
Embed | Plain Text
// This function looks for all vars sent through the address bar function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } // This looks to see if 'sent' was a sent through the address bar and saves the value of 'sent' to a new varable called 'NewVar' var NewVar = getUrlVars()["sent"];
You need to login to post a comment.
