Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

unterminated string error

I've been editing my aspx pages with no problem, and now all of a sudden i'm getting this error for my javascript nav menu "unterminated string constant".  The weird thing is that it has been working fine for weeks and i have made no changes to it (i implement it in a user control).  Anyone deal with this kind of bug?  Here is the javascript that it says is invalid:

<TD height="29" bgColor="#c180ff" width="160" id="tablea2"><STRONG><FONT size="2"><script>document.write("<p>Today is " + DateString() + "</p>\n");</script></FONT></STRONG></TD>



if thats a bit tough to read through, here is just the javascript:

<script>document.write("<p>Today is " + DateString() + "</p>\n");</script>

Any one deal with this?  Again, i have not made any changes to my javascript at all, only some of my aspx pages, and only now it is giving me this error

grover
Monday, November 01, 2004

oh yeah, just to clarify something, all of that is on one line of code in my source, so from <TD> to </TD> is not broken up into 2 lines.  Not sure if it means anything...

grover
Monday, November 01, 2004

another note, if i comment out that function call, the next javascript function call gives me an error...this line of code now

<script language="javascript">obtainPageTitle();</script>

grover
Monday, November 01, 2004

Not sure if it'll help but recently I ran into the 'Unterminated string constant' error myself.  What I was doing was mixing html and c# script (no code behind class) in one file like such:

<html>
  .
  .
  .
</html>
<script language="csharp" runat="server">
function foo()
{
  Response.Write("<script>self.close();</script>");
}
</script>

...and doing this would cause the 'Unterminated String Constant' error.  I traced it to the closing script tag in the string constant passed to Response.Write() - apparently the forward slash was hosing things up.  What I had to do was move the Response.Write("<script>self.close;</script>") to a function located in a compiled class and just call it from foo().

Not sure if this'll help any but what you're experiencing might be the case of the asp.net engine interpreting your script as c# and it's giving you the same error I saw.  Maybe try putting in a languate="javascript" attribute in your script tag.

Hope that made sense.  :-)

Good luck.

smallbiz
Monday, November 01, 2004

tried the language=javascript thing, same error, it seems i get the error on any javascript function call within this page.  I'm crying right now

grover
Monday, November 01, 2004

figured it out...missed a quote in a function called on page load....i'm an idiot

grover
Monday, November 01, 2004

*  Recent Topics

*  Fog Creek Home