Click to See Complete Forum and Search --> : unterminated string constant


Sue Stephen
10-31-2004, 04:16 PM
Hi,
I am using socket on linux to write a html page to left frame of a frameset from right frame to the client.
In C++ program......., in the middle of printing right frame:
-----------------------
string doc = "<html><body>";
doc += "<script language=\"javascript\">";
//other things can be added here...
doc += "</script>";
doc += "<input type=\"button\" value=\"Go\"></body></html>";

string write_menu = "top.frames[\"leftframe\"].document.write('" + doc + "');";

--------------------

write_menu is sent to client by socket.

However, each time I put the javascript tag <script></script> in doc, browser gives me "unterminated string constant" error.

By referring to:

http://www.webdeveloper.com/forum/showthread.php?threadid=17754&highlight=unterminated

I changed the line to "<\/script>", but it still does not work.

Could someone give some suggestions? Thank you very much for your help.



Sue

OneThoughtJay
10-31-2004, 06:49 PM
Originally posted by Sue Stephen
I changed the line to "<\/script>", but it still does not work.

Goodday Sue,

I do not know anything about C++ and it's literals, but I do know that "</script>" would cause the script the interpretate it as it's end. In JavaScript there are many ways to work around this, try something like the following:

"</" + "script>"

Hope this turns out in a satisfying result.

Yours wonderfully, :cool:
Jay