JavaScript encodeURIComponent() Function
- Previous Page encodeURI()
- Next Page escape()
- Go Up One Level JavaScript Global Reference Manual
Definition and Usage
encodeURIComponent()
The function encodes URI components.
This function encodes special characters. In addition, it also encodes the following characters: , / ? : @ & = + $ #
Tip:Use decodeURIComponent()
The function decodes encoded URI components.
Example
Encode URI:
var uri = "https://codew3c.com/my test.asp?name=stale&car=saab"; var res = encodeURIComponent(uri);
Syntax
encodeURIComponent(uri)
Parameter value
Parameter | Description |
---|---|
uri | Must. The URI to be encoded. |
Technical Details
Return Value: | A string representing the encoded URI. |
---|
Browser Support
Function | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
encodeURIComponent() | Support | Support | Support | Support | Support |
- Previous Page encodeURI()
- Next Page escape()
- Go Up One Level JavaScript Global Reference Manual