solved Syntax Error

derrickhand300
@derrickhand300
10 years ago
1,353 posts
Can someone correct the syntax error in the following?
<script type="text/javascript" data-cfasync="false">(function () { var done = 

false;var script = document.createElement('script');script.async = 

true;script.type = 'text/javascript';script.src = 

'https://app.purechat.com/VisitorWidget/WidgetScript';document.getElement

sByTagName('HEAD').item(0).appendChild

(script);script.onreadystatechange = script.onload = function (e) {if (!done && 

(!this.readyState || this.readyState == 'loaded' || this.readyState == 

'complete')) {var w = new PCWidget({ c: 'e5e9c6b0-7aa8-4392-a9d3-

6ff2b47cc3fa', f: true });done = true;}};})();</script>

I think it has something to do with the spacing of the smarty brackets....just not sure how to fix it
updated by @derrickhand300: 09/06/15 03:15:57PM
paul
@paul
10 years ago
4,335 posts
If this is in a template be sure to wrap it smarty {literal}{/literal} tags so that the smarty parser doesn't try to interpret the javascript curly (smarty) brackets.


--
Paul Asher - JR Developer and System Import Specialist
michael
@michael
10 years ago
7,816 posts
The culprit is that {var on line 15. and {if on line 11.

But paul brings up another way to approach the issue that is better in this case because you have a ton of stuff. If you wrap that whole block in {literal}{/literal} then you dont need to do that add a space between the bracket thing.

{literal}
// all that code in here.......
{/literal}
derrickhand300
@derrickhand300
10 years ago
1,353 posts
Thank you guys!

Tags