Navigator 2.0, Internet Explorer 3.0
escape(s)
The string that is to be "escaped" or encoded.
An encoded copy of s.
The escape() function is a built-in part of JavaScript; it is not a method of any object.
escape() creates and returns a new string that contains an encoded version of s. The string s itself is not modified.
The string is encoded as follows: all spaces, punctuation, accented characters, and any other characters that are not ASCII letters or numbers are converted to the form %xx, where xx is two hexadecimal digits that represent the ISO-8859-1 (Latin-1) encoding of the character. For example, the ! character has the Latin-1 encoding of 33, which is 21 hexadecimal, so escape() replaces this character with the sequence %21. Thus the expression:
escape("Hello World!");
yields the string:
Hello%20World%21
The purpose of the escape() encoding is to ensure that the string is portable to all computers, and transmittable across all networks, regardless of the character encodings the computers or networks support (as long as they support ASCII, however).
The encoding performed by escape() is like the standard URL-encoding used to encode query strings and other portions of a URL that might include spaces, punctuation, or characters outside of the standard ASCII character set. The only difference is that in the URL encoding, spaces are replaced with a `+' character, while escape() replaces spaces with the %20 sequence.
Use the unescape() function to decode a string encoded with escape().
A common use of escape() is to encode cookie values, which have restrictions on the punctuation characters they may contain. See "Document.cookie".
file: /Techref/language/java/script/definitive/refp_117.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/12 22:46,
18.222.107.27:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/Techref/language/java/script/definitive/refp_117.htm"> [Chapter 21] Reference: escape()</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.