encodeURI Function in JavaScript



The encodeURI() function accepts a string value representing an URI and encodes it by replacing the characters in it using numbers (1 to 4) and escape sequence.

Syntax

Its Syntax is as follows

encodeURIComponent('http://www.qries.com/');

Example

 Live Demo

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result1 = encodeURI('http://www.qries.com/?x=?????');
      document.write(result1);
      document.write("<br>");
      var result2 = encodeURI('http://www.tutorialspoint.com/?x=?????');
      document.write(result2);
   </script>
</body>
</html>

Output

http://www.qries.com/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B
http://www.tutorialspoint.com/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B
Updated on: 2020-06-25T13:05:23+05:30

110 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements