JavaScript encodeURI() function
- Forrige side decodeURIComponent()
- Næste side encodeURIComponent()
- Gå tilbage et niveau 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 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 supports
Funktion | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
encodeURI() | Support | Support | Support | Support | Support |
- Forrige side decodeURIComponent()
- Næste side encodeURIComponent()
- Gå tilbage et niveau JavaScript global reference manual