The decodeURI() function decodes a Uniform Resource Identifier (URI) previously created by encodeURI() or by a similar routine.
kinda de-facto standard yes. but only in modern browsers. its done for user convienience, so you can put utf8 charactesr in an url and its still pretty to the human eye. however please be aware that the text is actually still encoded and will be transmittet/requested encoded, it is only displayed decoded.
The encodeURIComponent() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).
Here is a complete function (taken from PHPJS):
function urldecode(str) {
return decodeURIComponent((str+'').replace(/\+/g, '%20'));
}
I've used encodeURIComponent() and decodeURIComponent() too.
Use this
unescape(str);
I'm not a great JS programmer, tried all, and this worked awesome!
decodeURIComponent(mystring);
you can get passed parameters by using this bit of code:
//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;
}
Or this one-liner to get the parameters:
location.search.split("your_parameter=")[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With