Forum : What is decodeURI(), encodeURI() in javascript?
Brief description  about Online courses   join in Online courses
View  's Profile

What is decodeURI(), encodeURI() in javascript?

what is the use of these function...
Asked by | Nov 4, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Naveen,

Many characters cannot be sent in a URL, but must be converted to their hex encoding. These functions are used to convert an
entire URI (a superset of URL) to and from a format that can be sent via a URI.

Here is an example:

<script type="text/javascript">

var test1="http://www.google.com/search?q=sonofusion Taleyarkhan";

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

</script>

Output :

http://www.google.com/search?q=sonofusion%20Taleyarkhan
http://www.google.com/search?q=sonofusion Taleyarkhan
Nov 4, 2009