JavaScript encodeURIComponent() Function
JavaScript Global 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
an encoded URI component.
Syntax
| Parameter |
Description |
| uri |
Required. The URI to be encoded |
Browser Support

The encodeURIComponent() function is supported in all major browsers.
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 Global Functions

The Altova MissionKit is an integrated suite of tools ideal for:
- XML development
- Web & Web services development
- Data mapping & integration
- Rendering & publishing XML & database data
- XBRL validation, taxonomy editing, transformation & rendering
The MissionKit for XML Developers includes XMLSpy® - the industry-leading XML editor; MapForce® - a
graphical data mapping, conversion, and integration tool; StyleVision® - a visual XSLT stylesheet designer;
DiffDog® - an XML-aware diff/merge tool; and 2 additional tools.
Try all 6 products free for 30 days!
Download a fully-functional free trial
|
|
|
|