Javascript examples for Global:decodeURIComponent
The decodeURIComponent() function decodes a URI component.
Parameter | Description |
---|---|
uri | Required. The URI to be decoded |
A String, representing the decoded URI
Decode a URI after encoding it:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w. ja v a 2s. 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>