MDN | MDN Curriculum | Playground | HTTP Observatory | About MDN | Advertise with us | Community | Blog | MDN Plus | MDN Discord | HTML: Markup language | Elements | Global attributes | Attributes | See all… | Responsive images | HTML cheatsheet | Date & time formats | See all… | SVG | MathML | XML | CSS: Styling language | Properties | Selectors | At-rules | Values | See all…
Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
A string to be encoded as a URI component (a path, query string, fragment, etc.). Other values are converted to strings.
encodeURIComponent() is a function property of the global object.
The following example provides the special encoding required within UTF-8 Content-Disposition and Link server response header parameters (e.g., UTF-8 filenames):
Encoding for Content-Disposition and Link headers
The following example provides the special encoding required within UTF-8 Content-Disposition and Link server response header parameters (e.g., UTF-8 filenames):
The more recent RFC3986 reserves !, ', (, ), and *, even though these characters have no formalized URI delimiting uses. The following function encodes a string for RFC3986-compliant URL component format. It also encodes
The more recent RFC3986 reserves !, ', (, ), and *, even though these characters have no formalized URI delimiting uses. The following function encodes a string for RFC3986-compliant URL component format. It also encodes
Encoding a lone surrogate throws
A URIError will be thrown if one attempts to encode a surrogate which is not part of a high-low pair. For example:
String.prototype.toWellFormed()
A URIError will be thrown if one attempts to encode a surrogate which is not part of a high-low pair. For example:
String.prototype.isWellFormed()
A URIError will be thrown if one attempts to encode a surrogate which is not part of a high-low pair. For example:
This page was last modified on Oct 30, 2025 by MDN contributors.