parse error upon including script

Started by ameo, May 24, 2015, 05:49:16 PM

Previous topic - Next topic

ameo


I wanna include script in my theme, but I get this:



Parse error: syntax error, unexpected ''+nice.version);' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in
index.template.php on line 119



<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.nicescroll/3.6.0/jquery.nicescroll.min.js"></script>
<script>
  $(document).ready(function() {
 
var nice = $("html").niceScroll();  // The document page (body)

$("#div1").html($("#div1").html()+' '+nice.version);
   
    $("#boxscroll").niceScroll({cursorborder:"",cursorcolor:"#00F",boxzoom:true}); // First scrollable DIV
    $("#boxscroll2").niceScroll("#contentscroll2",{cursorcolor:"#F00",cursoropacitymax:0.7,boxzoom:true,touchbehavior:true});  // Second scrollable DIV
    $("#boxframe").niceScroll("#boxscroll3",{cursorcolor:"#0F0",cursoropacitymax:0.7,boxzoom:true,touchbehavior:true});  // This is an IFrame (iPad compatible)

    $("#boxscroll4").niceScroll("#boxscroll4 .wrapper",{boxzoom:true});  // hw acceleration enabled when using wrapper
   
  });
</script>
antechinus:
QuoteIf you are dying for a solution it may be wise to seek medical attention.
Get some Awesome Smileys for your forum

|±(ಠ_ಠ
)±|

Shambles

You can't just splice into existing code, especially as you're inside an echo statement.

As a minimum, you need to replace

$("#div1").html($("#div1").html()+' '+nice.version);

.. with ..

Code (replace with) Select
$("#div1").html($("#div1").html()+\' \'+nice.version);

That escapes the single quotes with "\", to allow them to remain as single quotes within the echo statement.

ameo

antechinus:
QuoteIf you are dying for a solution it may be wise to seek medical attention.
Get some Awesome Smileys for your forum

|±(ಠ_ಠ
)±|

Advertisement: