JavaScript encodeURI() function
- Previous page decodeURIComponent()
- Next page encodeURIComponent()
- Go to the previous level JavaScript global reference manual
Definition and usage
encodeURI()
Function used to encode URI.
This function encodes special characters except: , / ? : @ & = + $ # (use encodeURIComponent() to encode these characters).
Tip:Use decodeURI()
Function to decode already encoded URI.
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 that represents the encoded URI. |
---|
browser supports
Function | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
encodeURI() | Support | Support | Support | Support | Support |
- Previous page decodeURIComponent()
- Next page encodeURIComponent()
- Go to the previous level JavaScript global reference manual