Skip to main content
Participant
January 6, 2012
Question

"There is a syntax error on line [x]..."

  • January 6, 2012
  • 2 replies
  • 19876 views

Hi,

I'm working in Dreamweaver CS5 (as a total novice), and have just received an error message saying "There is a syntax error on line 72. Code hinting may not work until you fix this error."

Line 72 in the coding simply says </script>

I'm doing everything graphically and haven't put anything into the coding myself, so I have no idea what this is all about, could someone please enlighten me as to what to do?

Thanks  

Alessio

    This topic has been closed for replies.

    2 replies

    Participant
    August 30, 2013

    The easiest way to resolve this for me has been to externalize your javascript in the template file.

    BenPleysier
    Community Expert
    Community Expert
    January 6, 2012

    Dear Alessio,

    The problem may not be on line 72, but within the script itself. If you want assistance, please let us be privy of the markup and scripts used. The best way to do this is to supply a link to a working online document.

    Gramps

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    MysticKnight
    Known Participant
    January 23, 2012

    I was using Dreamweaver CS5 without problem. Today I opened the same website in Dreamweaver 5.5 and it got the following syntax error notice...

    There is a syntax error on line 32. Code hinting may not work until you fix this error.

    I decided to create a new test.dwt file and I only have a single roll-over image on the page. Nothing else. When I created a page from the test.dwt file, it got the error message above.

    In other words, Dreamweaver doesn't like the script that it created to make the roll-over image. Here's the code that creates the error message...

    ------------------- Begin Example ---------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/test.dwt" codeOutsideHTMLIsLocked="false" -->

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <!-- InstanceBeginEditable name="doctitle" -->

    <title>Untitled Document</title>

    <!-- InstanceEndEditable -->

    <!-- InstanceBeginEditable name="head" -->

    <!-- InstanceEndEditable -->

    <script type="text/javascript">

    function MM_swapImgRestore() { //v3.0

      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;

    }

    function MM_preloadImages() { //v3.0

      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

        if (a.indexOf("#")!=0){ d.MM_p=new Image; d.MM_p[j++].src=a;}}

    }

    function MM_findObj(n, d) { //v4.01

      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

      if(!(x=d)&&d.all) x=d.all; for (i=0;!x&&i<d.forms.length;i++) x=d.forms;

      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

      if(!x && d.getElementById) x=d.getElementById(n); return x;

    }

    function MM_swapImage() { //v3.0

      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

       if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

    }

    </script>

    </head>

    <body onload="MM_preloadImages('images/navbar/cda_home-over.gif')">

    <a href="home.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/navbar/cda_home-over.gif',1)"><img src="images/navbar/cda_home.gif" alt="Home" name="home" width="149" height="33" border="0" id="home" /></a>

    </body>

    <!-- InstanceEnd --></html>

    ------------------- End Example ---------------------

    As you can see, it's a pretty simple page. Does anyone have any suggestions?

    Thanks in advance.

    Bill

    MysticKnight
    Known Participant
    January 24, 2012

    I think this is the problem...

    <!-- InstanceBeginEditable name="head" -->

    <!-- InstanceEndEditable -->

    That's exactly how Dreamweaver writes the code when you create a templete. However, I get the syntax error message if I leave it like that. All I did was move the 2nd line, <!-- InstanceEndEditable -->, to the bottom just below </head> and it fixed the syntax error message.

    ------------------- Begin Example ---------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/test.dwt" codeOutsideHTMLIsLocked="false" -->

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <!-- InstanceBeginEditable name="doctitle" -->

    <title>Untitled Document</title>

    <!-- InstanceEndEditable -->

    <!-- InstanceBeginEditable name="head" -->

    <script type="text/javascript">

    function MM_swapImgRestore() { //v3.0

      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;

    }

    function MM_preloadImages() { //v3.0

      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

        if (a.indexOf("#")!=0){ d.MM_p=new Image; d.MM_p[j++].src=a;}}

    }

    function MM_findObj(n, d) { //v4.01

      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

      if(!(x=d)&&d.all) x=d.all; for (i=0;!x&&i<d.forms.length;i++) x=d.forms;

      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

      if(!x && d.getElementById) x=d.getElementById(n); return x;

    }

    function MM_swapImage() { //v3.0

      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

       if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

    }

    </script>

    </head>

    <!-- InstanceEndEditable -->

    <body onload="MM_preloadImages('images/navbar/cda_home-over.gif')">

    <a href="home.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/navbar/cda_home-over.gif' ,1)"><img src="images/navbar/cda_home.gif" alt="Home" name="home" width="149" height="33" border="0" id="home" /></a>

    </body>

    <!-- InstanceEnd --></html>

    ------------------- End Example ---------------------

    It seems strange that Dreamweaver would make such an elementary mistake in writing this code. Also, it makes me very nervous moving around code manually in the template that Dreamweaver created to define all the pages at my website.

    Does anyone know if there's anything that I could have done wrong that caused this problem when Dreamweaver creates a template?

    All the best,

    Bill