I am building an auto-save feature for my TinyMCE editor.
With jQuery, I have saved the editor’s content to my database and now want to load the content back in to the editor. I am having troubles with the quotes (“) in the HTML coming from the DB.
My code:
var content = "<%=content%>" // Classic ASP variable containing HTML from DB
tinyMCE.activeEditor.setContent(content);
Example output:
var content = "<p>Oh yes, from Churchill, the <em><span style="text-decoration: underline;"><strong>dog</strong></span></em>.</p>"
tinyMCE.activeEditor.setContent(content);
In the variable, “content”, there are double quotes in the style tag which is causing a JS error. How do I get around this? Do I replace quotes with single quotes or do I use an escape or encode function? Please help.
VBScript has escaping functionality like Javascript (also ready if you use JScript as default language in classic asp)
Check out Escape and UnEscape.
Following is an efficient way of doing to append server-side variables to client-side js block.
Example output: