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

how to create a MultiLine string

I want to create a multiline string that can works in ie and
firefox,
who have a better idea ?

Aug 24 '07 #1
8 8008
I want to define a multiline string.

like:

var html = "<html>
<body>
</body>
</html>
.....
"
but i don't want to use '\'

Aug 24 '07 #2
hong hua wrote on 24 aug 2007 in comp.lang.javascript:
I want to define a multiline string.
Are you responding on a previous posting? [Re: ..]

Please always quote on usenet!
like:

var html = "<html>
<body>
</body>
</html>
....
"
Why do you want to do that, Hua?
but i don't want to use '\'
Why don't you want to do that?

How could you use '\' for that?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 24 '07 #3
if i want to store the following html code in a variable(javascript of
course) ,
Do you have a better idea?

================== HTML Start ======================
I want to define a multiline string.
Are you responding on a previous posting? [Re: ..]

Please always quote on usenet!
like:
var html = "<html>
<body>
</body>
</html>
....
"
<script language="javascript">
alert("hello world");
</script>
================= HTML End =======================

Aug 24 '07 #4
we*************@gmail.com wrote:
I want to define a multiline string.

like:

var html = "<html>
<body>
</body>
</html>
....
"
but i don't want to use '\'
var html = "<html>" +
"<body>" +
"<\/body>" +
"<\/html>";

http://javascript.crockford.com/
Aug 24 '07 #5
On Aug 24, 12:23 am, Douglas Crockford <nos...@sbcglobal.netwrote:
weizhonghua....@gmail.com wrote:
I want to define a multiline string.
like:
var html = "<html>
<body>
</body>
</html>
....
"
but i don't want to use '\'

var html = "<html>" +
"<body>" +
"<\/body>" +
"<\/html>";
Why escape the '/' on the closing tags? I have only read that is
necessary for script tags. Do HTML parsers exist that have a problem
with those closing tags or are you just being conservative?

I find it a easier to use single quotes when quoting HTML because then
attribute double quotes don't need escaping.

"<li id=\"foo\">"
'<li id="foo">'

Peter

Aug 24 '07 #6
Douglas Crockford wrote on 24 aug 2007 in comp.lang.javascript:
we*************@gmail.com wrote:
>I want to define a multiline string.

like:

var html = "<html>
<body>
</body>
</html>
....
"
but i don't want to use '\'

var html = "<html>" +
"<body>" +
"<\/body>" +
"<\/html>";

http://javascript.crockford.com/
But Douglas, she does not want to use "\"!

var sl = String.fromCharCode(47);

var html = '<html>' +
'<body>' +
'<'+sl+'body>' +
'<'+sl+'html>';

alert(html);
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 24 '07 #7
Douglas Crockford wrote:
we*************@gmail.com wrote:
>I want to define a multiline string.
[...]
but i don't want to use '\'

var html = "<html>" +
"<body>" +
"<\/body>" +
"<\/html>";
I would always prefer

var html = new Array(
"<html>",
" <body>"
" <\/body>",
"<\/html>"
).join("\n");

above that.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Aug 24 '07 #8
Thomas 'PointedEars' Lahn wrote:
Peter Michaux wrote:
>I find it a easier to use single quotes when quoting HTML because then
attribute double quotes don't need escaping.

"<li id=\"foo\">"
'<li id="foo">'

Add me. However, it is perfectly Valid to use apostrophes ("single quotes")
as attribute delimiter as well, even in X(HT)ML.
That should have been "attribute _value_ delimiter".
(Unfortunately, the SGML spec is not available free of charge at ISO.)
However, the SGML productions provide a fair idea:

http://www.w3.org/MarkUp/SGML/productions.html
http://www.w3.org/MarkUp/SGML/productions.html#prod32
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Aug 24 '07 #9

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

Similar topics

0
by: Rasmus Fogh | last post by:
Dear All, I need a way of writing strings or arbitrary Python code that will a) allow the strings to be read again unchanged (like repr) b) write multiline strings as multiline strings instead...
6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
4
by: Michael C | last post by:
Hi all, I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example): Line1 Line2 Line3 I've tried a couple of methods but nothing...
0
by: Anonieko Ramos | last post by:
> I have a graphics images that I want to convert to > ASCII art. How do I do it? > Code: - Default.aspx.cs
9
by: John Salerno | last post by:
How do you make a single string span multiple lines, but also allow yourself to indent the second (third, etc.) lines so that it lines up where you want it, without causing the newlines and tabs or...
9
by: Alex | last post by:
Hi all - Read here that embedding \n's into the tooltip string during runtime should yeild multiline tooltips. However, mine is just keeping the \n's in there and showing it all on one line....
2
by: BillE | last post by:
I need to create a multi-line label dynamically. Since labels aren't multi-line, I'm creating a textbox and making it look like a label with the multiline property set to true. I want to...
7
by: abcd | last post by:
When do I need to use a trailing slash to separate code over multiple lines. For example: x = "hello world, this is my multiline " + \ "string!!!!" x = {'name' : \ 'bob'}
7
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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.