JavaScript encodeURIComponent() Function
JavaScript Functions
Definition and Usage
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 URIs encoded with encodeURIComponent().
Syntax
| Parameter |
Description |
| uri |
Required. The URI to be encoded |
Example
Example
Encode an URI:
<script type="text/javascript">
var uri="http://w3schools.com/my test.asp?name=ståle&car=saab";
document.write(encodeURIComponent(uri));
</script>
|
The output of the code above will be:
|
http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab
|
Try it yourself »
|
JavaScript Functions
Click here to design a Stunning Flash Website for Free
Wix is a revolutionary web design tool that provides anyone with the possibility to create professional and beautiful websites for free.
With e-commerce features, search engine visibility and many more professional tools, Wix is the ultimate solution for creating a spectacular site while saving tons of money.
|