Easy Tutorial
❮ Dom Obj Radio Dom Obj Source ❯

JavaScript encodeURI() Function


Definition and Usage

The encodeURI() function encodes a string as a URI.

For the following ASCII punctuation marks that have special meanings in URIs, the encodeURI() function does not escape them: , / ? : @ & = + $ # (You can use the encodeURIComponent() method to encode these special ASCII punctuation marks individually.).

Note: Use the decodeURI() method to decode a URI (Uniform Resource Identifier).

Syntax

Parameter Description
uri Required. A string containing a URI or other text to be encoded.

Browser Support

All major browsers support the encodeURI() function.


Example

Encode a URI using encodeURI():

The above example outputs:

my%20test.php?name=st%C3%A5le&car=saab

❮ Dom Obj Radio Dom Obj Source ❯