SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie, LineBreak

    Code:
    document.write ("a=",a," and b=",b,"<br />");
    Instead of <br /> I try to do \n like in PHP but it won't work

    Code:
    document.write ("a=",a," and b=",b,"\n");
    document.write ("a=",a," and b=",b,'\n');
    document.write ("a=",a," and b=",b,\n); //fail

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using "\n" does add a line break. To your html. However, the browser ignores whitespace when rendering the page.

    To tell the browser to break to a new line, you need "<br />" or your content needs to be in a block level element.

  3. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shoot I was thinking something like that as I only use \n for form processing that I can think of. Thanks though, I just wanted the cleanest script I could do

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JREAM View Post
    Code:
    document.write ("a=",a," and b=",b,"<br />");
    That should be
    Code:
    document.write ("a=" + a + " and b=" + b + "<br>");


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •