I have an application, and it is fed some HTML. It then needs to put that HTML into a string. This HTML contains single and double quotes. Is it possible, in javascript, to declare a string with information inside of it, that does not use single or double quotes?
Thanks, and I guess if it is not possible, does anyone know a simple and easy way to escape these quotes so I can put it in a string? Keep in mind, part of this string will be javascript that I will later need to execute.
Thanks!
Use the
escape
function to replace special characters (including single and double quotes). You can then use theunescape
function to return the string to it's normal state later if necessary.For example:
An easy way to escape the quotes is to use the javascript escape function.
http://www.w3schools.com/jsref/jsref_escape.asp
You need to escape the quotation characters with
\
:No. JavaScript string literals are delimited with either single quotes or double quotes. Those are the only choices.
Do you mean in a string literal?
Or programmatically?