escape() [FF, IE 3]
Formats a string so that it conforms to URL encoding. Generally used for setting cookies (Chapter 12) and sending information to servers (Chapter 15 and Chapter 16).
Example:
var encoded_string = escape("a string safe for cookies");
The variable encoded_string
now holds a%20string%20safe%20for%20cookies
because the escape
function replaces spaces with %20
. See "unescape() [FF, IE 3]" on page 448 for more information.
Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.