473,799 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Untermina ted string
constant). Can any one please help me solving this bug.
strdata +="<tr <% if functionality_a dd = 0 and functionality_e dit = 0
and functionality_d elete = 0 then %>style='visibi lity:hidden'<% end if
%>><td valign=top colspan=2 class='formFiel d' height='25'
style='display: none' id='R_F" +curNode.item(0 ).text + "'><% if
functionality_a dd <> 0 or functionality_e dit <> 0 then %>Sub Region /
City: <% end if %><font color='#FF0000' size='2'>*</font>&nbsp;<inp ut
size='40' class='inputBox ' maxlength='200' type='text'
name='city_"+cu rNode.item(0).t ext +"'<% if functionality_a dd = 0 and
functionality_e dit = 0 then %>style='visibi lity:hidden'<% end if
%>>&nbsp;<selec t name='reg_type_ "+curNode.item( 0).text
+"'class='drpdw n' <% if functionality_a dd = 0 and functionality_e dit =
0 then %>style='visibi lity: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_a dd = 0 then
%>"style='visib ility:hidden'" <% end if %>><input class='Btn'
type=button value='Edit' name='edBtn2_"+ curNode.item(0) .text+"'
onclick='gotoEd itMode_2(" +curNode.item(0 ).text + ")' disabled <% if
functionality_e dit = 0 then %>style='visibi lity:hidden' <% end if
%>><input width=75 disabled name='delBtn2_" +curNode.item(0 ).text+"'
type='button' class='Btn' value='Delete' onclick='delreg ion(2)' <% if
functionality_d elete = 0 then %>style='visibi lity:hidden' <% end if
%></td></tr>"

Regards,
Amit Arora

Dec 8 '05 #1
3 4111
VK

aroraami...@gma il.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(Untermina ted 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+= "hhhhhhhhhhhhhh hhhhhhhh";
str+= "uuuuuuuuuuuuuu uuuuuuuu";
str+= "gggggggggggggg gggggggg";
str+= "eeeeeeeeeeeeee eeeeeeee";

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]
hhhhhhhhhhhhhhh hhhhhhh[backslash]
uuuuuuuuuuuuuuu uuuuuuu[backslash]
ggggggggggggggg ggggggg[backslash]
eeeeeeeeeeeeeee eeeeeee";

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.javas cript:

aroraami...@gma il.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(Untermina ted 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+= "hhhhhhhhhhhhhh hhhhhhhh";
str+= "uuuuuuuuuuuuuu uuuuuuuu";
str+= "gggggggggggggg gggggggg";
str+= "eeeeeeeeeeeeee eeeeeeee";

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]
hhhhhhhhhhhhhhh hhhhhhh[backslash]
uuuuuuuuuuuuuuu uuuuuuu[backslash]
ggggggggggggggg ggggggg[backslash]
eeeeeeeeeeeeeee eeeeeee";

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 =
'hhhhhhhhhhhhhh hhhhhhhh'+
'uuuuuuuuuuuuuu uuuuuuuu'+
'gggggggggggggg gggggggg'+
'eeeeeeeeeeeeee eeeeeeee';

var str =
'hhhhhhhhhhhhhh hhhhhhhh'
+'uuuuuuuuuuuuu uuuuuuuuu'
+'ggggggggggggg ggggggggg'
+'eeeeeeeeeeeee eeeeeeeee';

var str = ''.concat(
'hhhhhhhhhhhhhh hhhhhhhh',
'uuuuuuuuuuuuuu uuuuuuuu',
'gggggggggggggg gggggggg',
'eeeeeeeeeeeeee eeeeeeee');

var str = [
'hhhhhhhhhhhhhh hhhhhhhh',
'uuuuuuuuuuuuuu uuuuuuuu',
'gggggggggggggg gggggggg',
'eeeeeeeeeeeeee eeeeeeee']
..join('');

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

Dec 8 '05 #3
"VK" <sc**********@y ahoo.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]
hhhhhhhhhhhhhhh hhhhhhh[backslash]
uuuuuuuuuuuuuuu uuuuuuu[backslash]
ggggggggggggggg ggggggg[backslash]
eeeeeeeeeeeeeee eeeeeee";


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/rasterTriangleD OM.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
28433
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 virtual="checkQty.cgi?item='+itemtocheck+'"-->');
5
5718
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 appears to occur right after type='+typeIn+'&id <----before the = Any clues appreciated! Thanks, Kathy
6
13492
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 6.0 but if I take out the double quotes around header it does not? I need double quotes around header, I thought this was possible in javascript so long as the pair of double quotes is surrounded by a pair of single quotes.
2
2663
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 that contains some information, and i made it like a window, as in it can be maximized and closed by javascript functions in the page. the function operates on only one argument, and that is whether the visitor is maximizing or restoring the...
18
7340
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 processing: function saveText( scroll_list, t_area, listToBeUpdated ) { scroll_list.options.text = t_area.text; scroll_list.options.value= t_area.value; var req; var url = "http://mkmxg00/cgi/confirmUpload.pl";
2
16918
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, allso avant browser (shell for IE) dosent see it. the script works fine, i'm just anoyed with IE calling errors. Anybody know why this is?
5
13744
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: "Unterminated string constant" Here's my c# code: strText = "Line 1 text\nLine2 text"; Response.Write("<script>alert('" + strText + "');</script>");
2
3121
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 ("link1", "link2", "link3"); var links_text = new Array ("Link 1", "Link 2", "Link 3"); var links_url = new Array ("link1.htm", "link2.htm","link3.htm"); /* Resolve the location */ var loc=String(this.location);
1
5956
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 Cha\u00EEnes" then I get "Unterminated string constant" error. What fix would you suggest to keep div.innerHTML = "" format?
1
1667
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
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.