/ Published in: JavaScript
Read a page's GET URL variables and return them as an "associative array."
Calling the function while at `example.html?foo=asdf&bar=jkls` sets `map['foo']='asdf'` and `map['bar']='jkls'`
Calling the function while at `example.html?foo=asdf&bar=jkls` sets `map['foo']='asdf'` and `map['bar']='jkls'`
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getUrlVars() { var map = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { map[key] = value; }); return map; }