JavaScript encodeURIComponent() Function
Complete Function Reference
Definition and Usage
The encodeURI() function encodes a string as a component of a URI.
Syntax
encodeURIComponent(URIstring)
|
Parameter |
Description |
URIstring |
Required. The URI to be encoded |
Tips and Notes
Tip: Use the decodeURIComponent() function to decode URIs encoded
with encodeURIComponent().
Example
In this example we use encodeURIComponent() to encode URIs:
<script type="text/javascript">
document.write(encodeURIComponent("http://www.w3schools.com"));
document.write("<br />");
document.write(encodeURIComponent("http://www.w3schools.com/p 1/"));
document.write("<br />");
document.write(encodeURIComponent(",/?:@&=+$#"));
</script>
|
The output of the code above will be:
http%3A%2F%2Fwww.w3schools.com
http%3A%2F%2Fwww.w3schools.com%2Fp%201%2F
%2C%2F%3F%3A%40%26%3D%2B%24%23
|
Try-It-Yourself Demos
encodeURIComponent()
How to use encodeURIComponent() to encode different URIs.
Complete Function Reference
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|