How Do I Make Sure a String Is Safe to Use With JavaScript?

An article from coldfusion cookbook using jSStringFormat():

“If you are dynamically populating a JavaScript variable, you may find that your code breaks with “unterminated string constant” or similar error messages. This is probably a case of your JavaScript variables containing characters that are considers to be “special” characters by JavaScript. You will need to “escape” these special characters so that JavaScript can process them.”

Comments