Name

JSStringFormat — New as of ColdFusion 4.5

Synopsis

JSStringFormat(string)

Returns string with special characters escaped so that it is safe to use in JavaScript statements. Example:

<CFSET MyString="""Escape double quotes"".  Escape the \ character. 'Escape 
single quotes'">

<CFSET SafeString=JSStringFormat(MyString)>

<CFOUTPUT>
<B>Original String:</B> #MyString#<BR>
<B>JavaScript Safe String:</B> #SafeString#
</CFOUTPUT>

Get Programming ColdFusion 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.