#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    New learner with old book needs help


    I am trying to teach myself JavaScript using Don Gosselin’s book JavaScript Comprehensive, copyright 2000

    I realized first thing how out of date the book is since including the version of JavaScript in the <scrpt> tag means I get no output at all with my Internet Explorer.

    But now I am having trouble using the <pre>…</pre> tag with the writeln statement.

    I created this html file:
    Code:
    <html>
    <head>
    	<title>myfirstjavascript</title>
    </head>
    <body>
    	<pre>
    	<SCRIPT LANGUAGE="JavaScript">
    document.writeln("This is the first line in my JavaScript file.");
    document.writeln("This is the second line in my JavaScript file.");
    	</SCRIPT>
    	</pre>
    </body>
    </html>
    But using the <pre>…</pre> tags makes my Internet Explorer indent the first line with the second line being placed at the left margin. Does anyone know why?

    If I take out the <pre>…</pre> tags and use document.write() statements both lines of output are put together with nothing separating them:

    This is the first line in my JavaScript file.This is the second line in my JavaScript file.

    I get the same thing if I take out the <pre>…</pre> tags but keep the document.writeln() statements.

    How do I get lines of output on separate lines on the monitor without any indentations?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    26
    Rep Power
    0
    Code:
    <doctype html>
    <html>
    <head>
    <title>myfirstjavascript</title>
    </head>
    <body>
    <pre>
    <SCRIPT>
    document.writeln("This is the first line in my JavaScript file.");
    document.writeln("This is the second line in my JavaScript file.");
    </SCRIPT>
    </pre>
    </body>
    </html>
    Code:
    doctype html>
    <html>
    <head>
    <title>myfirstjavascript</title>
    </head>
    <body>
    
    <SCRIPT>
    document.writeln("This is the first line in my JavaScript file.");
    document.writeln("<br>");
    document.writeln("This is the third line in my JavaScript file.");
    </SCRIPT>
    
    </body>
    </html>
    Code:
    <doctype html>
    <html>
    <head>
    <title>myfirstjavascript</title>
    </head>
    <body>
    
    <SCRIPT>
    document.writeln("This is all one line ",
    "<br>",
    "in my JavaScript file.");
    </SCRIPT>
    
    </body>
    </html>

IMN logo majestic logo threadwatch logo seochat tools logo