Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 18th, 2011, 11:55 AM
Authorized User
Points: 109, Level: 2
Points: 109, Level: 2 Points: 109, Level: 2 Points: 109, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2011
Location: INDIA
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>
Reply With Quote
  #2 (permalink)  
Old February 18th, 2011, 03:10 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
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..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.