encodeURIComponent-1

 

encodeURIComponent will encode all the characters with special meaning. See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="encryptUrIComponent()">Encode the uri component</button> <p id="sample"></p> <script> function encryptUrIComponent() { var uri = "http://learnkode.com/Examples/Javascript/Javascript encodeURI functions"; var result = encodeURIComponent(uri); document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output