JavaScript encodeURIComponent() Function
The encodeURIComponent() function encodes a URI component. This function encodes special characters. In addition, it encodes the following characters: , / ? : @ & = + $ #. Tip: Use the decodeURIComponent() function to decode an encoded URI component.
Syntax
encodeURIComponent(uri)
Example:
<script language="JavaScript"> var uri="http://paktutorial.com/my test.asp?name=ståle&car=saab"; document.write(encodeURIComponent(uri)); </script>
Output:
http%3A%2F%2Fpaktutorial.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab
DOWNLOAD SOLUTION HERE
Pingback: Learn Javascript Step by Step | PakTutorial()