I am following this technique
http://modxcms.com/forums/index.php?topic=24164.5 to insert javascript in some pages. BUT I do not want to enter all the Javascript in the textarea of the TV, so I created a snippet and entered the javascript
<script type="text/javascript" language="javascript">
function xxx() { .....
}
</script>
can I do it? because it does not work... with or without the <?php and ?> makes no difference.
anybody has tried?
It gives me this error...
Parse error: syntax error, unexpected ’<’ in /home2/.../manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 1
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
snippets are only for php code, javascript will not work in a snippet. To use javascript either include it via a chunk or directly in the template.
Solved, it goes in a chunk... not a snippet...
on top of that... a snippet always inserts <?php and ?> in a snippet...
edit: thanks dev_cw
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
-
☆ A M B ☆
- 24,524 Posts
You can insert javascript using a snippet...
http://wiki.modxcms.com/index.php/API:regClientScript
http://wiki.modxcms.com/index.php/API:regClientStartupScript