JavaScript encodeURI() Function
Example
Encode a URI:
var uri = "my test.asp?name=ståle&car=saab";
var res = encodeURI(uri);
Try it Yourself »
Definition and Usage
The encodeURI() function is used to encode a URI.
This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters).
Tip: Use the decodeURI() function to decode an encoded URI.
Browser Support
Function | |||||
---|---|---|---|---|---|
encodeURI() | Yes | Yes | Yes | Yes | Yes |
Syntax
encodeURI(uri)
Parameter Values
Parameter | Description |
---|---|
uri | Required. The URI to be encoded |
Technical Details
Return Value: | A String, representing the encoded URI |
---|