JavaScript decodeURI() function : The decodeURI() function is used to decode the encoded URL.
Syntax of decodeURI() function :
decodeURI(uri)
uri : Required. This is the encoded url which need to encode.
Example of decodeURI() function : Following is the sample code which shows how to decode the encoded url in JavaScript.
<!DOCTYPE html>
<html>
<body>
<p>To decode a URI, click the button.</p>
<button onclick="convert()">convert</button>
<p id="container"></p>
<script>
function convert() {
var url = "process.html?name=John Smith&age=25";
var encoded = encodeURI(url);
var dec = decodeURI(encoded);
var result = "Encoded URI: " + encoded + "<br>" + "Decoded URI: " + dec;
document.getElementById("container").innerHTML = result;
}
</script>
</body>
</html>
Output :
Encoded URI: process.html?name=John%20Smith&age=25
Decoded URI: process.html?name=John Smith&age=25
0 Comment(s)