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.
<!--- This example shows the use of the JSStringFormat function. ----> <h3>JSStringFormat</h3> <cfset stringValue = "An example string value with a tab chr(8),
a newline (chr10) and some ""quoted"" 'text'"> <p>This is the string we have created:<br> <cfoutput>#stringValue#</cfoutput> </p> <cfset jsStringValue = JSStringFormat(#stringValue#)> <!----- Generate an alert from the JavaScript string jsStringValue. ----> <SCRIPT> s = "<cfoutput>#jsStringValue#</cfoutput>"; alert(s); </SCRIPT>
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting
Version 7
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000543.htm
Comments
MikerRoo said on May 24, 2005 at 8:05 PM : Alexander Bunkenburg said on May 26, 2005 at 1:52 AM :