JavaScript decodeURIComponent () function
Definition and Usage
decodeURIComponent () function can encodeURIComponent () function to decode the encoded URI.
Tip: Use encodeURIComponent () method can be encoded URI.
grammar
decodeURIComponent(uri)
参数 | 描述 |
---|---|
uri | 必需。一个字符串,含有编码 URI 组件或其他要解码的文本。 |
Browser Support
All major browsers support decodeURIComponent () function
Examples
Example
Use decodeURIComponent () to decode the encoded URI:
<script>
var uri="http://w3cschool.cc/my test.php?name=stale&car=saab";
var uri_encode=encodeURIComponent(uri);
document.write(uri_encode);
document.write("<br>");
document.write(decodeURIComponent(uri_encode));
</script>
var uri="http://w3cschool.cc/my test.php?name=stale&car=saab";
var uri_encode=encodeURIComponent(uri);
document.write(uri_encode);
document.write("<br>");
document.write(decodeURIComponent(uri_encode));
</script>
Examples of the above output:
http%3A%2F%2Fw3school.cc%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab
http://w3schools.com/my test.asp?name=stale&car=saab
http://w3schools.com/my test.asp?name=stale&car=saab
try it"
JavaScript Global Functions