How to use encodeURIComponent in JavaScript

This article describe about encodeURIComponent() Function in JavaScript.
  • 1805

encodeURIComponent() Function in JavaScript

For encode a URI component use encodeURICompent() function.

It is used to encode the special character like characters: , / ? : @ & = + $ #.

Note: To decode an encoded URI component use the decodeURIComponent().

Syntax

encodeURIComponent(uri)

 

Parameter Description
uri Required. uri to encoded.

Example

<!DOCTYPE html>

<html>

<body>

<script type="text/javascript">

    var uri = "https://dotnetheaven.com/default.aspx?name=ståle&car=raman";

    document.write(encodeURIComponent(uri));

</script>

</body>

</html>

 

Output

 

PIC2.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.