473,385 Members | 2,003 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,385 software developers and data experts.

Unterminated string literal in JS

I have a function to open new window:
function bla(){ newwin = window.open("page.asp?file=1&id=<%=ID
%>","Image","other params") }

This function works fine mostly, but sometimes, there is a JavaScript
error: "Unterminated string literal". This happens only in one case.
If you noticed ASP variable <%=ID%>, then here's what happens to it.
ID gets url parameter "id" and inserts in that JavaScript. Obviously,
this URL comes from another page. And when it comes from the page with
someurl.asp?id=123%0%DA, then my JavaScript throws this error.
If previous page URL is just someurl.asp?id=123, then JS works
perfect. Where is the catch?
Thank you.

Feb 28 '07 #1
7 25182
ASM
vu******@gmail.com a écrit :
I have a function to open new window:
function bla(){ newwin = window.open("page.asp?file=1&id=<%=ID
%>","Image","other params") }

This function works fine mostly, but sometimes, there is a JavaScript
error: "Unterminated string literal".
on which line of your code ?
with what browser ?
Obviously,
this URL comes from another page. And when it comes from the page with
someurl.asp?id=123%0%DA, then my JavaScript throws this error.
what does mean %0%DA ?
isn't it something missing ?
If previous page URL is just someurl.asp?id=123, then JS works
perfect.
However I tried with FF2 directly :
window.open("test.htm?file=1&id=%0%DA");
and ...
works fine
('id' has nonsense, but that works)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 28 '07 #2
On Feb 28, 1:50 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
vunet...@gmail.com a écrit :
I have a function to open new window:
function bla(){ newwin = window.open("page.asp?file=1&id=<%=ID
%>","Image","other params") }
This function works fine mostly, but sometimes, there is a JavaScript
error: "Unterminated string literal".

on which line of your code ?
with what browser ?
Obviously,
this URL comes from another page. And when it comes from the page with>someurl.asp?id=123%0%DA, then my JavaScript throws this error.

what does mean %0%DA ?
isn't it something missing ?
If previous page URL is just someurl.asp?id=123, then JS works
perfect.

However I tried with FF2 directly :
window.open("test.htm?file=1&id=%0%DA");
and ...
works fine
('id' has nonsense, but that works)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Browsers FF2 and IE7 tested. The same error.
Let's imagine I have a button "Edit Item", which has a hidden value
id=123. The id is taken from the url of this page, say, thispage.asp?
id=123. Form passes this id to anotherpage.asp which gets this id from
the form (with ASP: ID=request("id")) and inserts it into JS like
this:
function bla(){ newwin = window.open("thirdpage.asp?file=1&id=<%= ID
%>" ,"Image", "other params") }
This way it works. But if the same procedure is done starting with
page thispage.asp?id=123%0D%0A, error occurs as described above
"Unterminated string literal" and it even screws the following
functions in JS (they just do not exist).
Maybe I have to unescape url values or smth?

Feb 28 '07 #3
ASM
vu******@gmail.com a écrit :
On Feb 28, 1:50 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
>However I tried with FF2 directly :
window.open("test.htm?file=1&id=%0%DA");
and ...
works fine
('id' has nonsense, but that works)
This way it works. But if the same procedure is done starting with
page thispage.asp?id=123%0D%0A, error occurs as described above
Ha Ha ! it is not %0%DA as given previously
but ... %0D%0A

Anyway %0D or %0A to my idea can't exist
(%A0 or %D0 or %DA or %AD could be ok)

http://www.miakinen.net/vrac/charsets/
"Unterminated string literal" and it even screws the following
functions in JS
normal, on an error JS stops there.

Maybe I have to unescape url values or smth?
No, you have to correct you picking-up asp function

or to search which element in your form could give this value
(probably a character bad translated between iso-smth to/from utf-8 ?)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Feb 28 '07 #4
On Feb 28, 4:01 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
vunet...@gmail.com a écrit :
On Feb 28, 1:50 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
However I tried with FF2 directly :
window.open("test.htm?file=1&id=%0%DA");
and ...
works fine
('id' has nonsense, but that works)
This way it works. But if the same procedure is done starting with
page thispage.asp?id=123%0D%0A, error occurs as described above

Ha Ha ! it is not %0%DA as given previously
but ... %0D%0A

Anyway %0D or %0A to my idea can't exist
(%A0 or %D0 or %DA or %AD could be ok)

http://www.miakinen.net/vrac/charsets/
"Unterminated string literal" and it even screws the following
functions in JS

normal, on an error JS stops there.
Maybe I have to unescape url values or smth?

No, you have to correct you picking-up asp function

or to search which element in your form could give this value
(probably a character bad translated between iso-smth to/from utf-8 ?)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
are you saying that in ASP: ID=request("id") may obtain a bad value?
Sorry, i did not give the correct %0D%0A string in the first place.

Feb 28 '07 #5
vu******@gmail.com said the following on 2/28/2007 4:39 PM:

<snip>
are you saying that in ASP: ID=request("id") may obtain a bad value?
ASP may be giving a "good value" for ASP but the same value can be a
"bad value" for JS. Try having ASP escape the variable first.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 28 '07 #6
ASM
vu******@gmail.com a écrit :
are you saying that in ASP: ID=request("id") may obtain a bad value?
Sorry, i did not give the correct %0D%0A string in the first place.
%0D%0A = \r\n in JS, that's to say a return carriage

document.getElementById('info').innerHTML = escape('123%0D%0A456');

gives

<pre id='info'>
123
456
</pre>

alert(typeof('123%0D%0A')); tells it's a string

Do not understand where string is unterminated.

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 1 '07 #7
On Feb 28, 8:06 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
vunet...@gmail.com a écrit :
are you saying that in ASP: ID=request("id") may obtain a bad value?
Sorry, i did not give the correct %0D%0A string in the first place.

%0D%0A = \r\n in JS, that's to say a return carriage

document.getElementById('info').innerHTML = escape('123%0D%0A456');

gives

<pre id='info'>
123
456
</pre>

alert(typeof('123%0D%0A')); tells it's a string

Do not understand where string is unterminated.

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
the solution is unescape(<%=ItemID%>). thank you all for helping me. i
should have thought of this before...

Mar 2 '07 #8

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

Similar topics

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...
1
by: vanitha | last post by:
Hi All, I am using "C" to generate the javascript code. And i am getting the following error message "Unterminated string literal" in the mozilla webbrowser for the following syntax. unsigned...
3
by: aroraamit81 | last post by:
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...
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,...
1
by: larrylyons | last post by:
I don't understand why I'm getting Unterminated String Literal error MY JAVASCRIPT function test(){ newWindow =...
7
basstradamus
by: basstradamus | last post by:
Hi When I am trying to eveluate object literal It causing Unterminated string constans error (firefox). var obiekt = (eval("("+data+")")); the data is carring object literal recived from server...
2
by: wwolfson | last post by:
Hiya, Im trying to embed some Javascript into some xhtml which is embedded into a php file. The line causing a problem is this: <form id=\"deletetopic\" name=\"deletetopic\" method=\"post\"...
0
by: manojpolawar2008 | last post by:
Hi, I am using the fckeditor with asp.net2.0. I have declared and initialized and the FCKEditor on code behind(ie on aspx.vb) page. and i wan to set the ViewState value to FckEditor on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.