JavaScript encodeURI() Function
Complete Function Reference
Definition and Usage
The encodeURI() function encodes a string as a URI.
Syntax
Parameter |
Description |
URIstring |
Required. The URI to be encoded |
Tips and Notes
Note: The encodeURI() function encodes special characters, with the
exception of:
, / ? : @ & = + $ #. Use the encodeURIComponent() function to encode these characters.
Tip: Use the decodeURI() function to decode URIs encoded
with encodeURI().
Example
In this example we use encodeURI() to encode URIs:
<script type="text/javascript">
var test1="£€";
document.write(encodeURI(test1)+ "<br />");
document.write(decodeURI(test1));
</script>
|
The output of the code above will be:
Try-It-Yourself Demos
encodeURI()
How to use encodeURI() to encode different URIs.
Complete Function Reference
 |
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|