Don't embed scripts. Call functions in external scripts instead.
Your quotes need to be escaped.
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
thanks for the reply. But maybe you mis-understand my issue.
Here my problem is not the javascript code itself. But the java script can't assess the data inside
Test it with XHTML and see if you get anything.
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
If you need data constants, put them in the script, not in the HTML.
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
The reason i want to put it in CDATA, is that I want to put some template html data which may include many lines of HTML source. While it's possible to put the whole template inside the javascript string, but it's quite ugly as i have to use the code like: "line1\n" + "line2" + ....., and if i have single or double quote inside the template, i have escape that, which will make the javascript code more ugly. I just want a cleaner way to let javascript read the template from some external source.
You can place the data in a separate file and load it into the page later using XMLHttpRequest or similar, if you don't need it right away.
You can place it in the HTML of the page and apply a CSS style to hide it.
<div style="display:none;">data here...</div>
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101