Use the server-side language to generate the javascript:
// JSP
var jsvar = "${ jspVar }";
// PHP
var jsvar = "<?php echo $phpVar ?>";
If the string contains a quote mark, it will have to be escaped.
If the an inline-script tag is used, and the string must not
contains characters such as ` < `, ` > `, ` & `.
The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/
--
The sendings of these daily posts are proficiently hosted
by http://www.pair.com.
// Ruby
var jsvar = "<%= rubyVar %>";
[...]
> If the an inline-script tag is used, and the string must not
> contains characters such as ` < `, ` > `, ` & `.
That sentence sounds strange. Maybe something like this is better:
"If inline script tag is used, the string must not contain characters
such as '<', '>' and '&'"
[...]
--
kangax