www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Unterminated string literal?

  1. #1
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582

    resolved [RESOLVED] Unterminated string literal?

    Hello, everyone.

    Got one that's making me scratch my head, a lot.

    I keep getting an 'unterminated string literal' error message.
    Code:
    incJS += '<script type="text/javascript" src="' + thisRoot + 'scripts/application/FP.js"></script>';
    According to FF Error Console, it exists right at the end of the </script> tag.

    I'm not seeing it. What am I missing?

    Thanks,
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    What's the line before and after, particularly before?
    Great wit and madness are near allied, and fine a line their bounds divide.

  3. #3
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Thanks for the response, Declan, but I finally figured it out; although I don't remember this ever being a problem, before.

    The string was being terminated early because I was not escaping forward slashes with a backslash.

    Incorrect:
    incJS += '<script type="text/javascript" src="' + thisRoot + 'scripts/application/FP.js"></script>';
    Correct:
    incJS += '<script type="text\/javascript" src="' + thisRoot + 'scripts\/application\/FP.js"><\/script>';

    Sigh
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  4. #4
    Join Date
    Mar 2011
    Posts
    60
    It's because of the script closing tag inside the string. When you don't escape or split it like
    '<scr'+'ipt>' it's seen as the close tag of your script.

  5. #5
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582

    Talking

    Dangit. I should have fingered that one out. Didn't even think of it. Thanks for the info.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles