[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/encodeURI [Back]  [Original]

encodeURI() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

encodeURI()

20157

encodeURI() (URI) ( UTF-8 ) "" )

encodeURI(URI)

URI

URI

(URI)

URI URI URI

http://username:password@www.example.com:80/path/to/file.php?foo=316&bar=this+has+spaces#anchor

encodeURI UTF-8

; , / ? : @ & = + $
- _ . ! ~ * ' ( )
#

encodeURI HTTP GET POST URI XMLHTTPRequests "&", "+", "=" GET POST encodeURIComponent

- URIError

js
//  -  ok
console.log(encodeURI("\uD800\uDFFF"));

//  "Uncaught URIError: URI malformed"
console.log(encodeURI("\uD800"));

//  "Uncaught URIError: URI malformed"
console.log(encodeURI("\uDFFF"));

URL RFC3986 ( IPv6) URL ()

js
function fixedEncodeURI(str) {
  return encodeURI(str).replace(/%5B/g, "[").replace(/%5D/g, "]");
}

ECMAScript 2027 LanguageSpecification
# sec-encodeuri-uri


Web Proxy Viewer  |  New URL  |  Original Page