Click to See Complete Forum and Search --> : Line Continuation
gnikr
01-22-2003, 02:38 PM
I'm new to Javascript and was wondering if there is any way for javascript to do a line continuation like the exaple below.
document.write("This is some text
and here is some more");
Webskater
01-22-2003, 02:40 PM
Originally posted by gnikr
I'm new to Javascript and was wondering if there is any way for javascript to do a line continuation like the exaple below.
document.write("This is some text \n
and here is some more");
gnikr
01-22-2003, 03:03 PM
Thanks for the response but it didn't seem to work. Nothing prints out when there are multi-line strings. I forgot to mention that the problem I'm having is with Netscape 7.0.
I have attached my code.
<script LANGUAGE="JavaScript">
if (nBoth == "Netscape 5.0") {
document.write ( nBoth && " Doesn't Work On This Page \n
<br>Line 2");
}else{}
</script>
<script LANGUAGE="JavaScript">
if (nBoth == "Netscape 5.0") {
document.write ( nBoth && " Doesn't Work On This Page \n
<br>Line 2");
}else{}
</script>
First of all, this script in itself wont don't do anything.
1. Did you define nBoth earlier? If not, it's not going to do antying like this.
2. nBoth && "text... should be nBoth += "text... (assuming that you defined nBoth earlier)
Second, this is how you do a line break
<script type="text/javascript">
document.write("This is some text<br/>and here is some more");
</script>
Dan Drillich
01-22-2003, 03:22 PM
The following also works -
document.write("This is some text" ,
" and here is some more");
gnikr
01-22-2003, 03:28 PM
I'm not asking the question correctly as well as not coding correctly, so I'll start over.
Line 1. nName = navigator.appName;
Line 2. nVer = navigator.appVersion;
Line 3. nVer = nVer.substring(0,3);
Line 4. nBoth = nName.concat(" ",nVer);
Line 5. <script LANGUAGE="JavaScript">
Line 6. if (nBoth == "Netscape 5.0") {
Line 7. document.write ( nBoth && " Doesn't Work On This Page,
Line 8. Code on Line 2,
Line 9. Code on Line3.");
Line 10. }else{}
Line 11. </script>
How do you continue a line in JS with document.write? I would like the above example to print out: "Netscape 5.0 Doesn't Work On This Page, Code on Line 2, Code on Line3" I'm not worried about HTML line breaks only carrage returns in the actual code.
gnikr
01-22-2003, 03:30 PM
Dan, thanks for your reply it worked perfectly.
Gnikr