Home >
Technical & Creative Skills >
Programming, Servers & Scripts
getURLParameter that replaces symbols? (4)
08-15-2018 08:40 PM
#1
steel rain (Member)
getURLParameter that replaces symbols?
This is what the average getURLParameter looks like:
Code:
function getURLParameter(name) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] === name){return pair[1];}
}
return "";
}
However, when getting "ISP" for example you can get the name shown as "Cooperativa+Telefonica+Del+Viso" in your lander.
Does anyone have a function that has a replace built in it?
So you can use it in landers that use the function this way:
Code:
document.write(getURLParameter('isp'))
Thanks
08-16-2018 10:23 AM
#2
matuloo (Legendary Moderator)
Had to move the thread to another section, since you posted in a forum part that is moderated. So a bump for you to get some eyeballs on it 
08-16-2018 10:39 AM
#3
manu_adefy (Veteran Member)

Originally Posted by
steel rain
This is what the average getURLParameter looks like:
function getURLParameter(name) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] === name){return pair[1];}
}
return "";
}
However, when getting "ISP" for example you can get the name shown as "Cooperativa+Telefonica+Del+Viso" in your lander.
Does anyone have a function that has a replace built in it?
So you can use it in landers that use the function this way:
document.write(getURLParameter('isp'))
Thanks
Try this:
Code:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || ''
);
}
08-16-2018 11:42 AM
#4
steel rain (Member)

Originally Posted by
manu_adefy
Try this:
Code:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || ''
);
}
This works perfectly. Thank you.

Originally Posted by
matuloo
Had to move the thread to another section, since you posted in a forum part that is moderated. So a bump for you to get some eyeballs on it

Thanks
Home >
Technical & Creative Skills >
Programming, Servers & Scripts