473,396 Members | 1,772 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,396 software developers and data experts.

problem with a string

Hi all...

I got this script where I have to declare a string thats as wide as a whole
webpage. The problem is that it takes several lines to finish the whole
string and, when I try to load it, I get an error saying that there was a
caracter expected at the end of the line... Does anybody know how can I make
notice that my variable is several lines wide?
<html>
<head>
<title>Dovip 845 Navigator</title>
<meta http-equiv=\"Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="50">
<script type="text/javascript">
function contrasenya()
{
var elhtm="<table width=\"90%\" align=\"center\" cellpadding=\"0\"
cellspacing=\"0\"><tr><td width=\"27%\"><strong><font size=\"5\"
face=\"Courier New, Courier, mono\" color=\"#009900\">Safe</font><font
size=\"5\" face=\"Courier New, Courier, mono\"
color=\"#CC0033\">Line,S.L.</font></strong></td><td
width=\"7%\">&nbsp;</td><td width=\"56%\"><strong><font color=\"#009966\"
face=\"Courier New, Courier, mono\">Estado del equipo :</font><font
color=\"#CC0000\">¿%$P ¿%$Q \"><font
color=\"#00FF00\">&nbsp; ¿%$p </font></td><td bgcolor=\"#000000\"><font
color=\"#CCCCCC\">0.3mS - 5mS</font></td><td bgcolor=\"#000000\"><font
color=\"#00FF00\">&nbsp; ¿%$x ¿%$q </font></td></tr></table>\";
var a=prompt("escribe la contraseña");
if (a=="safeline") endavant(elhtm);
else barrera();
}
function endavant(elhtm)
{
document.getElementById("writeArea").innerHTML=elh tm
function barrera()
{
document.getElementById("writeArea").innerHTML="Co ntraseña incorrecta!!!!
Refresca la pagina y escribe la contraseña correcta."; }
</script>
</head>
<body onLoad="contrasenya()" bgcolor="#FF9900" text="#000000"nk="#0000CC">
<div id="writeArea"></div>
</body>
</html>


/* if reduced elhtm so it's not so big, but you'd have to see it as a var
that gets to the end of the line and keeps on, thus making my browser as for
the end of the var (";" at the end of the line, instead of keeping on
reading....

Any idea?

Yodai */
Jul 20 '05 #1
1 1306
On Wed, 14 Jan 2004 18:20:41 GMT, Yodai <yo***@spamnot.mail.vu> wrote:
<title>Dovip 845 Navigator</title>
<meta http-equiv=\"Content-Type" content="text/html; charset=iso-8859-1"> ^
I don't think that, the backslash, should be there.
<meta http-equiv="refresh" content="50">
<script type="text/javascript">
function contrasenya()
{
var elhtm="<table width=\"90%\" align=\"center\" cellpadding=\"0\"
cellspacing=\"0\"><tr><td width=\"27%\"><strong><font size=\"5\"
face=\"Courier New, Courier, mono\" color=\"#009900\">Safe</font><font
size=\"5\" face=\"Courier New, Courier, mono\"
color=\"#CC0033\">Line,S.L.</font></strong></td><td
width=\"7%\">&nbsp;</td><td width=\"56%\"><strong><font color=\"#009966\"
face=\"Courier New, Courier, mono\">Estado del equipo :</font><font
color=\"#CC0000\">¿%$P ¿%$Q \"><font
color=\"#00FF00\">&nbsp; ¿%$p </font></td><td
bgcolor=\"#000000\"><font
color=\"#CCCCCC\">0.3mS - 5mS</font></td><td bgcolor=\"#000000\"><font
color=\"#00FF00\">&nbsp; ¿%$x ¿%$q </font></td></tr></table>\";
If you notice, you escape the final double-quote mark. As far as the
JavaScript parser is concerned, you haven't terminated the string.

Rather than escaping all of the quotes, make life easier for your self;
use single-quotes (') for JavaScript strings and double-quotes inside
them. Also, instead of one huge string, break it up into several
concatenated strings. Lastly, though you escaped the nested double-quotes,
you didn't escape the forward slashes[1]. Some browsers (certainly used
to) interpret the sequence, </ as the end of script and style blocks, even
if in full the sequence was </TABLE>, for example. Instead make sure you
do <\/. All of these recommendations result in this:

var elhtm = '<table width="90%" align="center" cellpadding="0"'
+ ' cellspacing="0"><tr><td width="27%"><strong><font size="5"'
+ ' face="Courier New, Courier, mono" color="#CC0033">Line,S.L.'
+ '<\/font><\/strong><\/td><td width="7%">&nbsp;<\/td><td'
+ ' width="56%"><strong><font color="#009966" face="Courier New,'
+ ' Courier, mono">Estado del equipo :<\/font><font'
+ ' color="#CC0000">¿%$P ¿%$Q "><font'
+ ' color="#00FF00">&nbsp; ¿%$p <\/font><\/td><td'
+ ' bgcolor="#000000"><font color="#CCCCCC">0.3mS - 5mS<\/font>'
+ '<\/td><td bgcolor="#000000"><font color="#00FF00">&nbsp;'
+ ' ¿%$x ¿%$q <\/font><\/td><\/tr><\/table>';

<snip>
function endavant(elhtm)
{
document.getElementById("writeArea").innerHTML=elh tm


You're missing the terminating semi-colon (;) and closing brace (}).

<snip>

Mike
[1] I don't know if this is still an issue, but as I was recently reminded
of it whilst reading the HTML specification, I thought I'd mention it.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

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

Similar topics

18
by: muser | last post by:
is string converted to its integer equivalent by minusing it by 48? the function is suppose to check the fifth digit of struct member using the formula contained within the function. The function...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
7
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user...
4
by: David Scemama | last post by:
Hi, I'm trying to read a database file written from a turbo Pascal program. I've set a structure to map the records in the file, but I have problem reading the file when I use VBFixedArray in...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
8
by: Rinaldo | last post by:
Hi, When I start my program in the debugger, there is no problem, but when not I get an exception. It appears in: private void Upload(string filename, string FTnaam) { MessageBox.Show("in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.