homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

unterminated string literal

10+ Year Member

Msg#: 3818720 posted 2:24 am on Jan 4, 2009 (gmt 0)


I know what the error means, but I just can't spot where it's occuring and Firebug isn't much of a help either...

could you try to spot it for me?

<a href="#" onClick="insertText('<p>Lorem ipsum text text text <a href=&quot;http://www.example.com/support/download_details.jsp?id=209&quot;>text text</a> text text.</p>
<p>text, text &quot;text&quot; text. Text &quot;text&quot;. Text, text &quot;Text&quot; text &quot;text&quot; text &quot;text&quot; text.</p>');">Text, text: "text".</a>

the javascript function itself works fine, just not for some type of text, this specific part of text, which needs to be inserted into a textarea when a user clicks on a link, apparently contains something which borks up the javascript....help?

[edited by: coopster at 10:12 pm (utc) on Jan. 4, 2009]
[edit reason] generalized domain and text [/edit]



WebmasterWorld Senior Member 5+ Year Member

Msg#: 3818720 posted 4:39 am on Jan 4, 2009 (gmt 0)

A line line between the two paragraphs maybe ?


WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 3818720 posted 7:41 am on Jan 4, 2009 (gmt 0)

my guess is the closing </a> tag in the quoted string should be encoded.
try using the &lt; and &gt; html entities for all the tags in the quoted string.


10+ Year Member

Msg#: 3818720 posted 10:10 am on Jan 4, 2009 (gmt 0)

thanks people, it indeed had to do with a carriage return....

been bugging me for hours!
since the string came out of PHP, I just stripped it all like:

$text = str_replace(chr(13), " ", $text); //remove carriage returns
$text = str_replace(chr(10), " ", $text); //remove line feeds

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved