I am using the following cut/paste function to get the URL parameters.
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
var i = 0;
for(i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
It works perfectly fine but when I get a URL like:
http://example.com/login.html?redirecturl=http://example.com/game_detail.html?id=3&reminderid=5
and I do something like:
loginVars = getUrlVars();
alert("redirecting to: "+loginVars['redirecturl']);
I get only:
redirecting to: http://example.com/game_detail.html?id
but what I want is the whole: http://example.com/game_detail.html?id=3&reminderid=5
As I said, in general you can not ‘guess’, especially when parameters (by RFC) belong to the original URL, not to the URL inside of one of those parameters, but in application to your example you can use