Last updated on
Description
Escapes special JavaScript characters, such as single-quotation mark, double-quotation mark, and newline.
Returns
A string that is safe to use with JavaScript.
Category
Syntax
JSStringFormat(string)
Parameters
Parameter |
Description |
---|---|
string |
A string or a variable that contains one. |
Usage
Escapes special JavaScript characters, so you can put arbitrary strings safely into JavaScript.
Example
<cfscript> stringValue = "An example string value with a tab chr(8), a newline (chr10) and some ""quoted"" 'text'" jsStringValue = JSStringFormat(#stringValue#) writeOutput(jsStringValue) // An example string value with a tab chr(8), \na newline (chr10) and some \"quoted\" \'text\' </cfscript>
Output
An example string value with a tab chr(8), \na newline (chr10) and some \"quoted\" \'text\'