Encode URL with encodeURI

Description

encodeURI() is used to encode URIs to be passed to the browser.

It is designed to work on an entire URI.

encodeURI() does not encode special characters that are part of a URI, such as the colon, forward slash, question mark, and pound sign

Example


var uri = "http://www.java2s.com/illegal value.htm#start";
console.log(encodeURI(uri));

The code above generates the following result.





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window