Wrox Programmer Forums
|
BOOK: Beginning JavaScript 4th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 4th Edition by Paul Wilton, Jeremy McPeak; ISBN: 978-0-470-52593-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 4th Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 18th, 2011, 11:55 AM
Authorized User
 
Join Date: Feb 2011
Posts: 19
Thanks: 2
Thanked 1 Time in 1 Post
Default line feed

by write this code i'm not getting bob and tom in two line.
it comes on a single line



Quote:
<script type="text/javascript">
document.write("bob \n tom");

</script>
 
Old February 18th, 2011, 03:10 PM
jmcpeak's Avatar
Wrox Author
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Howdy, pramuk97.

The document object's write() method writes HTML markup to the document loaded in the browser. Your code equates to the following markup:

Code:
bob
tom
Load that in any browser, and you won't see a line break between "bob" and "tom". That's because a browser does not format text based on line feeds or whitespace (except for single spaces between words); text is formatted by using HTML elements. So when you want to format any text in a web page, you have to use HTML elements. What you want to do is this:

Code:
document.write("bob <br/> tom");

Last edited by jmcpeak; February 18th, 2011 at 03:13 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Line feed in plain text email takabyte PHP How-To 1 November 29th, 2007 03:09 PM
How to draw indicator line in owc line chart AlexOo General .NET 0 July 9th, 2007 10:32 PM
How to read file line by line in EVC++ iriskab Visual C++ 0 September 27th, 2006 01:39 PM
Reading line by line from a .txt file x_ray VB.NET 2002/2003 Basics 5 February 10th, 2006 01:55 PM
Read LF(Line Feed) at the end of the lines rylemer Pro VB 6 1 April 30th, 2004 02:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.