X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Internet Explorer Firefox Opera Google Chrome Safari

The encodeURI() function is supported in all major browsers.


Syntax

encodeURI(uri)

Parameter Values

Parameter Description
uri Required. The URI to be encoded

Return Value

Type Description
String The encoded URI


Function Reference JavaScript Global Functions

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook