THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript encodeURI() Function

Function Reference JavaScript Global Functions

Example

Encode a URI:

var uri = "my test.asp?name=ståle&car=saab";
var res = encodeURI(uri);

The result of res will be:

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

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

Function Reference JavaScript Global Functions

COLOR PICKER

colorpicker

SHARE THIS PAGE






Search w3schools.com:

Translate w3schools.com: