Description
The escape() function encodes a string. It is used to make strings portable, so they can be transmitted across any network to any computer that supports ASCII characters.
This function encodes special characters, with the exception of: * @ - _ + . /
This method has the form:
escape(string)
Parameter | Description |
---|---|
string | (required) The string to be encoded |
Examples
The following example shows the basic use of this method.
<script>
var msg = "Got sun? Visit Hawaii!";
document.write(escape(msg));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|
Description
The unescape() function decodes an encoded string.
This method has the form:
unescape(string)
Parameter | Description |
---|---|
string | (required) The string to be decoded |
Examples
The following example shows the basic use of this method.
<script>
var msg = "Got%20sun%3F%20Visit%20Hawaii%21";
document.write(unescape(msg));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|