473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

unterminated string constant

Hi,

I am facing a problem in javascript. strdata is a variable of
javascript and following is an assignment( hmmmmmmmmmmm a Huge one but
unfortunately its not mine code, I am just trying to rectify it) to
this varibale.. Now I am facing a run time error(Unterminated string
constant). Can any one please help me solving this bug.
strdata +="<tr <% if functionality_add = 0 and functionality_edit = 0
and functionality_delete = 0 then %>style='visibility:hidden'<% end if
%>><td valign=top colspan=2 class='formField' height='25'
style='display:none' id='R_F" +curNode.item(0).text + "'><% if
functionality_add <> 0 or functionality_edit <> 0 then %>Sub Region /
City: <% end if %><font color='#FF0000' size='2'>*</font>&nbsp;<input
size='40' class='inputBox' maxlength='200' type='text'
name='city_"+curNode.item(0).text +"'<% if functionality_add = 0 and
functionality_edit = 0 then %>style='visibility:hidden'<% end if
%>>&nbsp;<select name='reg_type_"+curNode.item(0).text
+"'class='drpdwn' <% if functionality_add = 0 and functionality_edit =
0 then %>style='visibility:hidden'<% end if %>><option value=1>Sub
Region</option><option value=2>City</option></select><input class='Btn'
type=button name='addBtn2_"+curNode.item(0).text+"' value='Add'
onClick='submit_form(2)'" <% if functionality_add = 0 then
%>"style='visibility:hidden'" <% end if %>><input class='Btn'
type=button value='Edit' name='edBtn2_"+curNode.item(0).text+"'
onclick='gotoEditMode_2(" +curNode.item(0).text + ")' disabled <% if
functionality_edit = 0 then %>style='visibility:hidden' <% end if
%>><input width=75 disabled name='delBtn2_"+curNode.item(0).text+"'
type='button' class='Btn' value='Delete' onclick='delregion(2)' <% if
functionality_delete = 0 then %>style='visibility:hidden' <% end if
%></td></tr>"

Regards,
Amit Arora

Dec 8 '05 #1
3 4089
VK

aroraami...@gmail.com wrote:
Hi,

I am facing a problem in javascript. strdata is a variable of
javascript and following is an assignment( hmmmmmmmmmmm a Huge one but
unfortunately its not mine code, I am just trying to rectify it) to
this varibale.. Now I am facing a run time error(Unterminated string
constant). Can any one please help me solving this bug.


It is not a bug: new line cannot be used inside of a string literal.

The conventional way for long literals is:

var str = "";
str+= "hhhhhhhhhhhhhhhhhhhhhh";
str+= "uuuuuuuuuuuuuuuuuuuuuu";
str+= "gggggggggggggggggggggg";
str+= "eeeeeeeeeeeeeeeeeeeeee";

There is also a native (means common for all JavaScript/JScript
implementations) model failure exploit which allows you to do things
like:
(Google news swallows the backslashes, so instead of a real one I'm
using [backslash] marker)

var str = "[backslash]
hhhhhhhhhhhhhhhhhhhhhh[backslash]
uuuuuuuuuuuuuuuuuuuuuu[backslash]
gggggggggggggggggggggg[backslash]
eeeeeeeeeeeeeeeeeeeeee";

Note that [backslash] must to be the last char in the string. Also as
any exploit it is not guranteed to stay forever.

Dec 8 '05 #2
VK wrote on 08 dec 2005 in comp.lang.javascript:

aroraami...@gmail.com wrote:
Hi,

I am facing a problem in javascript. strdata is a variable of
javascript and following is an assignment( hmmmmmmmmmmm a Huge one but
unfortunately its not mine code, I am just trying to rectify it) to
this varibale.. Now I am facing a run time error(Unterminated string
constant). Can any one please help me solving this bug.


It is not a bug: new line cannot be used inside of a string literal.

The conventional way for long literals is:

var str = "";
str+= "hhhhhhhhhhhhhhhhhhhhhh";
str+= "uuuuuuuuuuuuuuuuuuuuuu";
str+= "gggggggggggggggggggggg";
str+= "eeeeeeeeeeeeeeeeeeeeee";

There is also a native (means common for all JavaScript/JScript
implementations) model failure exploit which allows you to do things
like:
(Google news swallows the backslashes, so instead of a real one I'm
using [backslash] marker)

var str = "[backslash]
hhhhhhhhhhhhhhhhhhhhhh[backslash]
uuuuuuuuuuuuuuuuuuuuuu[backslash]
gggggggggggggggggggggg[backslash]
eeeeeeeeeeeeeeeeeeeeee";

Note that [backslash] must to be the last char in the string. Also as
any exploit it is not guranteed to stay forever.


var str =
'hhhhhhhhhhhhhhhhhhhhhh'+
'uuuuuuuuuuuuuuuuuuuuuu'+
'gggggggggggggggggggggg'+
'eeeeeeeeeeeeeeeeeeeeee';

var str =
'hhhhhhhhhhhhhhhhhhhhhh'
+'uuuuuuuuuuuuuuuuuuuuuu'
+'gggggggggggggggggggggg'
+'eeeeeeeeeeeeeeeeeeeeee';

var str = ''.concat(
'hhhhhhhhhhhhhhhhhhhhhh',
'uuuuuuuuuuuuuuuuuuuuuu',
'gggggggggggggggggggggg',
'eeeeeeeeeeeeeeeeeeeeee');

var str = [
'hhhhhhhhhhhhhhhhhhhhhh',
'uuuuuuuuuuuuuuuuuuuuuu',
'gggggggggggggggggggggg',
'eeeeeeeeeeeeeeeeeeeeee']
..join('');

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 8 '05 #3
"VK" <sc**********@yahoo.com> writes:
There is also a native (means common for all JavaScript/JScript
implementations)
That's a broad sweep :)
model failure exploit which allows you to do things like:
(Google news swallows the backslashes, so instead of a real one I'm
using [backslash] marker)

var str = "[backslash]
hhhhhhhhhhhhhhhhhhhhhh[backslash]
uuuuuuuuuuuuuuuuuuuuuu[backslash]
gggggggggggggggggggggg[backslash]
eeeeeeeeeeeeeeeeeeeeee";


While it might work in most Javascript implementations, what it means
is different. In some browsers, the "backslash newline" is not in the
resulting string (e.g., IE, Opera and Mozilla), in others the newline
itself is escaped and occurs in the string (e.g., Netscape 4).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Dec 8 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: noViagraHere | last post by:
What do i need to add to the document line to stop getting an Unterminated String Constant error? itemtocheck = '1300'; document.writeln('<!--#include...
5
by: KathyB | last post by:
Hi, this is the first lines of a function. Although it runs, it still throws an "Unterminated string constant" error in the browser. It is all in one line, just wouldn't fit here. The error...
6
by: Jeff | last post by:
Hi, does anyone know why this: <a onclick="insertatcaret(window.opener.document.formname.fieldname,'<td class="header">')">text</a> returns a "Unterminated String Constant" error message in IE...
2
by: Tav | last post by:
this seems to be a very generic error message, and the fact that i have no way of locating what causes the error is frustrating. anyway, i'll be general with my problem. i have a div on my page...
18
by: William | last post by:
I have the following javascript function that updates a scroll_list and sends the updated entry (with its index) to a server script ( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further...
2
by: polilop | last post by:
When i open my page in IE it shows an error Unterminated string constant om Line..... When i look at the line it shows the line where the </SCRIPT> tag is ???? Moziila dose not see this error,...
5
by: ken s | last post by:
From server-side code I'm using Response.Write to display a javascript alert box. It works fine except when I try to include a new line character, which causes this javascript error: ...
2
by: rajuk | last post by:
Hi i have following code,when i execute this code i got unterminated string constant error.any javascript guru can you look into this please. raju /* The link details */ var links = new Array...
1
by: VUNETdotUS | last post by:
Let's say I have a string: div.innerHTML = "<a onclick='foo(\""+myWord+"\");'></a>"; in IE only (tested version 7) if var myWord = "English" then it works fine but if var myWord = "Modifier...
1
by: buntyindia | last post by:
I am getting the following string from the database using Java Text <p>hi m</p> <p>Do Something</p> <p>&nbsp;</p> that I have to load into a javascript based rich text editor.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.