getting URL parameters in javascript

Apr 29, 01:58 AM

this is an easy way to get URL parms in jscript:

copied from here


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;
}

alert (‘one is equal to ‘ + getUrlVars()[‘ThisIsAParameterForYou’] ); // easy!

Mark Edwards

,

---

Commenting is closed for this article.

---