Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JavaScript encodeURIComponent() Function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 241
    Comment on it

    The URI component encoding is yield by the function called encodeURIComponent(). This function encodes special characters like this: , / ? : @ & = + $ #. We can use the decodeURIComponent() function to decode an encoded URI component.

    Syntax:

    encodeURIComponent(uri)
    

    It returns a string representing the encoded URI.

    Example:

    <!DOCTYPE html>
    <html>
    <body>
    
    <button onclick="encodeFunction()">click here to see encoding</button>
    
    <p id="view"></p>
    
    <script>
    function encodeFunction() {
        var uri = "http://w3schools.com/my test.asp?name=stle&car=saab";
        var res = encodeURIComponent(uri);
        document.getElementById("view").innerHTML = res;
    }
    </script>
    
    </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: