The encodeURI() function is used to encode a URI.
The encodeURI() function is used to encode a URI.
This function encodes special characters, except: , / ? : @ & = + $ #
You can use encodeURIComponent() to encode these characters.
encodeURI(uri)
Parameter | Require | Description |
---|---|---|
uri | Required. | The URI to be encoded |
A String, representing the encoded URI
Encode a URI:
var uri = "my test.asp?name=json&lang=java"; var res = encodeURI(uri); console.log(res);