encodeURI-1

 

encodeURI is use to encode the URI, In this example, the input is "http://learnkode.com/Examples/Javascript/Javascript encodeURI functions" and this will get converted to "http://learnkode.com/Examples/Javascript/Javascript%20encodeURI%20functions". See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="encryptUri()">Encode the uri</button> <p id="sample"></p> <script> function encryptUri() { var uri = "my page.asp?name=michael&car=voughan"; var result = encodeURI(uri); document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output