//parse URL to get values: var i = getUrlVars()["i"];
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
//How decodeURIComponent Works
function proURIDecoder(val)
{
val=val.replace(/\+/g, '%20');
var str=val.split("%");
var cval=str[0];
for (var i=1;i<str.length;i++)
{
cval+=String.fromCharCode(parseInt(str[i].substring(0,2),16))+str[i].substring(2);
}
return cval;
}
document.write(proURIDecoder(window.location.href));
var url = "http://www.mynewsfeed.com/articles/index.php?id=17";
var encoded_url = encodeURIComponent(url);
var decoded_url = decodeURIComponent(encoded_url);