Global decodeURI() Function - Javascript Global

Javascript examples for Global:decodeURI

Description

The decodeURI() function decodes a URI.

Parameter Values

Parameter Description
uri Required. The URI to be decoded

Return Value:

A String, representing the decoded URI

The following code shows how to Decode a URI after encoding it:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/* ww w. j  a v  a2 s.  c o m*/
    var uri = "https://example.com/my test.asp?name=st?le&car=saab";
    var uri_enc = encodeURIComponent(uri);
    var uri_dec = decodeURIComponent(uri_enc);
    var res = "Encoded URI: " + uri_enc + "<br>" + "Decoded URI: " + uri_dec;
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials