Javascript examples for Global:decodeURI
The decodeURI() function decodes a URI.
Parameter | Description |
---|---|
uri | Required. The URI to be decoded |
A String, representing the decoded URI
The following code shows how to Decode a URI after encoding it:
<!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>