My HTML page loads with a sent visitor. The request looks like this:
http://mydomain.com/index.html?success_url[]=http://www.google.com
(sometimes browsers seem to request this instead
http://mydomain.com/index.html?success_url[]=http%3A%2F%2Fwww.google.com
And I need to do some differing Javascript stuff depending on what URL is passed as an URI string. I got it working in my own installation of IE, Chrome & Firefox, but when I pushed it live it apparently did not work for a lot of people. I have not been able to replicate any problems but I know it didn't work for one person running Chrome on a Mac.
Here is the code I was running:
Code:
<script language="JavaScript">
var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
query = query.replace('[]', '');
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
}
}
}
qsParm['success_url'] = null;
qs();
var suxess;
suxess = qsParm['success_url'];
suxess = decodeURIComponent(suxess);
switch(suxess)
{
case 'http://google.com':
sitename = 'Google';
break;
case 'http://facebook.com':
sitename = 'Facebook';
break;
}
</script>
I'm not sure how to proceed with this. My google powers failed to yield anything beyond producing the code above. I can't find anything specific regarding brackets in URI string names, and colons, slashes in URIs.. And I've learned everything backwards so I don't know what I should read up on.
Can anyone see any reason as to why this would fail for anyone?
PS. I have no influence over the URI content.
PPS. Is it possible it fails because the brackets gets encoded for some and is therefore not removed in line 5 of the posted code?