Results 1 to 8 of 8

Thread: document.writeln only one line

  1. #1

    Thread Starter
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    document.writeln only one line

    when i use document.writeln(text) the string in text (in this case paragraphs of info) are only displayed on one line

    i need to know away so that like in html the text that will not fit in the window is rolled over to the next line

    thanks

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    If I understand you it should do that, it sounds like you've put it into a <pre> element or something. Try this for example:

    Code:
    <script type="text/javascript"><!--
    document.open();
    document.writeln('<p>This is some long paragraph text, that should enable you to break down a line <\/p>');
    document.close();
    //--></script>

  3. #3

    Thread Starter
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    i havent put in any kind a pre element im trying to use documentiwriteln to print a varable that holds text on mutiple line like this (but this doesnt work):

    Code:
    <script type="text/javascript"><!--
    var text = "blablablaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    document.open();
    document.writeln('<p>' + text + '<\/p>');
    document.close();
    //--></script>

  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Works for me Can up put the page up on the internet so we can take a look?

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by dogfish227
    i havent put in any kind a pre element im trying to use documentiwriteln to print a varable that holds text on mutiple line like this (but this doesnt work):

    Code:
    <script type="text/javascript"><!--
    var text = "blablablaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    document.open();
    document.writeln('<p>' + text + '<\/p>');
    document.close();
    //--></script>
    Are you saying that you want the <P> on one line, the text on another line, and the </P> on yet another line?
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

  7. #7
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    OH I see what you mean. Well I think that's just HTML, if there's no where to break it won't break. There are a few solutions. You can either use characters like - or a space or something like that to wrap at those points. Or you can use a soft hypen, that says to the browser "if you need to you can wrap here, but put a hypen there if you do". You can use the ­ entity where you think the text should wrap:

    Code:
    var text = "bla&amp;shy;bla&amp;shy;blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&amp;shy;bla­bla&amp;shy;blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&amp;shy;bla&amp;shy;bla&amp;shy;blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    But that's a limitation of HTML (as far as I know) I'm afraid. There may be a fix in CSS, but I'm not sure.

  8. #8

    Thread Starter
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    the ­ work fine ill just make a simple program that takes the paragraph and puts those where the spaces are so i want have to tyoe it out a hundred times

    thanks for your hepl

Posting Permissions

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



Click Here to Expand Forum to Full Width