Home  >  Article  >  Web Front-end  >  How to use javascript escape method

How to use javascript escape method

青灯夜游
青灯夜游Original
2021-11-04 14:38:323846browse

In JavaScript, the escape() method is used to encode a string so that the string can be read on all computers; syntax "escape(string)".

How to use javascript escape method

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

The escape() function encodes a string so that it can be read on all computers.

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

Syntax: escape(string)

Note: The escape() function cannot be used to encode URIs (UniformResourceIdentifier, referred to as "URI")). You can use the function encodeURI() instead.

Example:

<script>
document.write(escape("欢迎来到PHP中文网!"));
</script>

Output result:

How to use javascript escape method

##[Recommended learning:

javascript advanced tutorial]

The above is the detailed content of How to use javascript escape method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn