EscapeJavascriptString

Mon 01 January 2018

Syntax

EscapeJavascriptString(String)

Description

Use the EscapeJavascriptString function to replace the characters in String that have special meaning in a JavaScript string as escape sequences.

For example, a single quotation mark` ( ' ) is replaced by \', a new line character is replaced by \n, and so on.

This function is for use with text that becomes part of a JavaScript program.

The characters that are replaced are ones that cause the browser to misinterpret the JavaScript if they aren't encoded. This function is intended to make the text “browser safe.” The table below shows the strings that are replaced by this function, and their replacement character sequence.

Character Name

Glyph

Description

Apostrophe, single quote

'

\'

Quotation mark

"

\"

New line

Not applicable

\n

Carriage return

Not applicable

Deleted

Double backslash

\\

\\\\

Parameters

Field or Control

Definition

String

Specify a string that contains character that need to be replaced with JavaScript escape sequences.

Returns

A string containing the original text plus JavaScript escape sequences.