JavaScript encodeURI() function
- Previous Page decodeURIComponent()
- Next Page encodeURIComponent()
- Go Up One Level JavaScript Global Reference Manual
Definition and usage
encodeURI()
The function is used to encode URIs.
This function encodes special characters except: , / ? : @ & = + $ # (use encodeURIComponent() to encode these characters).
Tip:Use decodeURI()
The function decodes a URI that has already been encoded.
Example
Encode URI:
var uri = "my test.asp?name=ståle&car=saab"; var res = encodeURI(uri);
Syntax
encodeURI(uri)
Parameter value
Parameter | Description |
---|---|
uri | Required. The URI to be encoded. |
Technical details
Return value: | A string representing the encoded URI. |
---|
Browser support
Function | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
encodeURI() | Support | Support | Support | Support | Support |
- Previous Page decodeURIComponent()
- Next Page encodeURIComponent()
- Go Up One Level JavaScript Global Reference Manual