fix getURLParam to actually parse and decode parameters correctly

This commit is contained in:
Jon Atkins 2014-11-24 17:13:00 +00:00
parent a1fc33dcc7
commit 02f41d41eb

View File

@ -76,13 +76,19 @@ window.layerGroupLength = function(layerGroup) {
// retrieves parameter from the URL?query=string. // retrieves parameter from the URL?query=string.
window.getURLParam = function(param) { window.getURLParam = function(param) {
var v = document.URL; var items = window.location.search.substr(1).split('&');
var i = v.indexOf(param); if (items == "") return "";
if(i <= -1) return '';
v = v.substr(i); for (var i=0; i<items.length; i++) {
i = v.indexOf("&"); var item = items[i].split('=');
if(i >= 0) v = v.substr(0, i);
return v.replace(param+"=",""); if (item[0] == param) {
var val = item.length==1 ? '' : decodeURIComponent (item[1].replace(/\+/g,' '));
return val;
}
}
return '';
} }
// read cookie by name. // read cookie by name.