unescape()

JavaScript 1.0+, JScript 1.0+, ECMAScript 1.0+ NES2+, Nav2+, IE3+, Opera3+ Syntax

unescape(string)

Description

The unescape() method takes a hexadecimal value and returns the ISO-Latin-1 ASCII equivalent. This method performs the opposite operation of the escape() method and is commonly used to escape user-entered data before form submission.

Example

Listing 6.269 declares a local variable, escapedVal, and passes it to the unescape() method. The result, "@", is then written to the page.

Listing 6.269 Using the unescape() Method to Convert a Hexadecimal Value to its ASCII Equivalent
 <script language="JavaScript"> <!–– Hide // create a variable var escapedVal = "%40"; // evaluate the variable and place the value in a variable ...

Get Pure JavaScript 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.