Javascript code in TCM gets quotes changed
-
So if I include in my TCM code block the following code:
<!-- Special offer timer implementation --> <script> function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i <ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; }
(and things continue from there)
Then what actually gets expanded into the HTML when my page is served is:
<script defer="defer"> function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i <ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; }
So the entity expansion with ampersands causes syntax errors which cause the Javascript not to work… I can just put the Javascript into a separate file but it’s easier for me to work being able to edit the short script right in the TCM. Is there any way to fix this and still have the code editable in the TCM?
Thanks in advance for your help.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Javascript code in TCM gets quotes changed’ is closed to new replies.