Latest web development tutorials

JavaScript escape () function

Function Reference Manual JavaScript Global Functions

Definition and Usage

escape () function encodes a string, the string so that you can read on all computers.

This method does not encode ASCII letters and numbers, nor will the following ASCII punctuation Code: * @ - _ + /. All other characters will be replaced with escape sequences.

Tip: Use theunescape () method of the string to decode.

grammar

escape(string)

参数 描述
string 必需。要被转义或编码的字符串。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support escape () function


Tips and Notes

Note:. Escape () function can not be used for encoding URIs (Universal Resource Identifier (UniformResourceIdentifier, referred to as the "URI")) You can use the function encodeURI () replaced.


Examples

Examples

Use escape () to encode the string:

<script>

document.write(escape("Need tips? Visit W3Cschool!"));

</script>

Examples of the above output:

Need%20tips%3F%20Visit%20W3Cschool%21

try it"


Function Reference Manual JavaScript Global Functions