<!DOCTYPE html> <html> <body> <p>Click the button to decode a URI after encoding it.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var uri = "my test.asp?name=stale&car=saab"; var enc = encodeURI(uri); var dec = decodeURI(enc); var res = "Encoded URI: " + enc + "<br>" + "Decoded URI: " + dec; document.getElementById("demo").innerHTML = res; } </script> </body> </html>