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

writeln and new line (\n) not working


Hello NG,
I have been making all my web pages in HTML and I just started using
JavaScript yesterday and ran into a brick wall!
I can get the escape character " \n " or document.writeln to give me a new
line.
Or for that matter any of the form feed " \f " or carriage return " \r
" to work either.
I can get the escape character " \" "
I'm using XP home with SP2 with IE6 all my security setting set to Prompt
so if that was an issue then at least I should get a prompt for allowing the
script to work.
I put my JavaScript in a .js file and have referenced it from the HTML page.
I've tried this on different machines that also use XP with IE6, is this a
problem with IE?
I've tried
<script type= "text/javascript" src="assets/beagle.js">
and
<script language="JavaScript1.2" src="assets/beagle.js">
Any ideas as to where I'm going wrong?
================================================== =========
here is the HTML part
<html>
<head>
<title> Welcome to my Beagle Page</title>
<!-- place all scripts below, in this area -->
<script language="JavaScript1.2" src="assets/beagle.js">

<!--

-->
</script>

<!-- place all scripts above, in this area -->

</head>
<body>
<CENTER><H1><FONT COLOR="#0000FF">Beagle Page</FONT></H1></CENTER>
</body>
</html>

================================================== ===========
and here is the beagle.js file

document.writeln("\"Welcome to my site! \"");
document.writeln("\n")
document.writeln
document.writeln("This page created by James Last update:\n" +
document.lastModified);

document.bgColor="black"
document.fgColor="#336699"
window.alert("Welcome to my site!")

================================================== =============
Thaks for any suggestions
James
"Go outside - the graphics are amazing!"
Jan 20 '06 #1
4 13202
James wrote on 20 jan 2006 in comp.lang.javascript:
<html>
<head>
<title> Welcome to my Beagle Page</title>
<!-- place all scripts below, in this area -->
<script language="JavaScript1.2" src="assets/beagle.js">
So not sepecify the 1.2 and the wrong string, use:

<script type="text/JavaScript" src="assets/beagle.js">
<!--
do not use!
-->
do not use.
</script>

<!-- place all scripts above, in this area -->
Exept scripts with displayable html text, they should be in the <body>

</head>
<body>
<CENTER><H1><FONT COLOR="#0000FF">Beagle Page</FONT></H1></CENTER>
better use css:

<div style='text-align:center;color:#00f;'>
Beagle Page
</div>



</body>
</html>

================================================== ===========
and here is the beagle.js file

document.writeln("\"Welcome to my site! \"");
document.writeln("\n")
Probably you want tos show new lines in the browser, so use:
document.write('"Welcome to my site!"');
document.write("<br>")
document.writeln in contrast to document.write gives only an extra new
line in the internal source, that you won't see anyway without special
measures. so better use the latter.
document.writeln
not useful, leave out, or write a <br>.
document.writeln("This page created by James Last update:\n" +
same, \n will only affect the internal source code.
document.lastModified);

document.bgColor="black"
It is the body that uses colours, not documents:

document.body.bgColor="black"
document.fgColor="#336699"
but better use css styles:

document.body.style.backgroundColor = 'black';
document.body.style.color = '#369';

single quotes and end colon are optional, but advised.
window.alert("Welcome to my site!")



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 20 '06 #2
"James" <tvwatchr2@NO_SPAMearthlink.net> wrote in message
news:sh*************@newsread2.news.pas.earthlink. net...

Hello NG,
I have been making all my web pages in HTML and I just started using
JavaScript yesterday and ran into a brick wall!
I can get the escape character " \n " or document.writeln to give me a new line.
Or for that matter any of the form feed " \f " or carriage return " \r
" to work either.
I can get the escape character " \" "
I'm using XP home with SP2 with IE6 all my security setting set to Prompt
so if that was an issue then at least I should get a prompt for allowing the script to work.
I put my JavaScript in a .js file and have referenced it from the HTML page. I've tried this on different machines that also use XP with IE6, is this a
problem with IE?
I've tried
<script type= "text/javascript" src="assets/beagle.js">
and
<script language="JavaScript1.2" src="assets/beagle.js">
Any ideas as to where I'm going wrong?
================================================== =========
here is the HTML part
<html>
<head>
<title> Welcome to my Beagle Page</title>
<!-- place all scripts below, in this area -->
<script language="JavaScript1.2" src="assets/beagle.js">

<!--

-->
</script>

<!-- place all scripts above, in this area -->

</head>
<body>
<CENTER><H1><FONT COLOR="#0000FF">Beagle Page</FONT></H1></CENTER>
</body>
</html>

================================================== ===========
and here is the beagle.js file

document.writeln("\"Welcome to my site! \"");
document.writeln("\n")
document.writeln
document.writeln("This page created by James Last update:\n" +
document.lastModified);

document.bgColor="black"
document.fgColor="#336699"
window.alert("Welcome to my site!")

================================================== =============
Thaks for any suggestions
James
"Go outside - the graphics are amazing!"


You are using JavaScript to render HTML; therefore,
use "<br>" not "\n".

Here it is without the "include". Watch for word-wrap.

<html>
<head>
<title>Welcome to my Beagle Page</title>
<script type="text/javascript">
document.writeln("\"Welcome to my site! \"");
document.writeln("<br>This page created by James Last update:<br>" +
document.lastModified);
document.bgColor="black"
document.fgColor="#336699"
window.alert("Welcome to my site!")
</script>
</head>
<body>
<CENTER><H1><FONT COLOR="#0000FF">
Beagle Page</FONT></H1></CENTER>
</body>
</html>
It's not too readable with that color scheme!
Jan 20 '06 #3
Thanks for the help.
Things are working for me now and I learned something in the process
James

--

"Go outside - the graphics are amazing!"

Jan 20 '06 #4
On 2006-01-20, James <tvwatchr2@NO_SPAMearthlink.net> wrote:

Hello NG,
I have been making all my web pages in HTML and I just started using
JavaScript yesterday and ran into a brick wall!
I can get the escape character " \n " or document.writeln to give me a new
line.
Or for that matter any of the form feed " \f " or carriage return " \r
" to work either.


those symbols are only significant inside <pre> sections of your document
outside of them use <br> for as line break eg. document.write("<br>");

Bye.
Jasen
Jan 21 '06 #5

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

Similar topics

3
by: Jason Cook | last post by:
What is the difference?
2
by: Christopher Benson-Manica | last post by:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">...
2
by: eels | last post by:
Hello, I want to open a new window with javascript: secondWindow=window.open(...) secondWindow.document.writeln(...) I wrote the javascript code into a separate file secondwindow.js. I...
3
by: sam | last post by:
Hi Just encountered a strange problem and wonder if it is a bug ? I have the following piece of code.... try { IHTMLDocument2 MyDoc = (IHTMLDocument2 MyWebBrowser.Document; IHTMLWindow2 ...
1
by: Mark Overstreet | last post by:
I am creating an asp.net app and all I am trying to do is Console.Writeln(somevariable) but this does not should up in the output window? I feel pretty stupid but does anyone have any idea why I...
6
by: tony | last post by:
Hello! When you have windows forms you have the same possibility as when you have a Console application to use Console.Writeln to write whatever on the screen. Now to my question: Is it...
0
by: yoni | last post by:
Hi, In order to debug i filled my C# code with Trace.WriteLn messages. Then i downloaded DbgView and run it. My understanding is that as i run my code, i suppose to see all the messages in...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
4
by: nareshtatipelli | last post by:
Hi, I want to open a image in new window from one tool. In IE7 window.open giving Access Denied error. So, I have used following code function newWindow() { var msg='<html><body><form><img...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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.