Escapes special JavaScript characters, such as single-quotation mark, double-quotation mark, and newline.
A string that is safe to use with JavaScript.
JSStringFormat(string)
Parameter |
Description |
|---|---|
string |
A string or a variable that contains one. |
Escapes special JavaScript characters, so you can put arbitrary strings safely into JavaScript.
<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\'
Sign in to your account