How to use encodeURI in JavaScript

This article describe about encodeURI() Function in JavaScript.
  • 1780

encodeURI() Function in JavaScript

It is used to encode the URL. And encodes the special characters, except: , / ? : @ & = + $ # ( encodeURIComponent() to encode these characters).

Note: decodeURI() function to decode an encoded URI

Syntax

encodeURI(uri)

 

Parameter Description
uri Required. the URI to encoded.

 

Example

 

<!DOCTYPE html>

<html>

<body>

<script type="text/javascript">

    var uri = "default.aspx?name=ståle&car=raman";

    document.write(encodeURI(uri) + "<br />");

</script>

</body>

</html>

 

Output

 

pic1.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.