how to place a <br> in a javascriptfunction?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fjodor Klondyke

    how to place a <br> in a javascriptfunction?

    hello,

    i have a function in javascript. when someone clicks on a link the text in a
    layer changes.
    i want breaks in the text, in html you would use '<br><br>'.
    i tried this in the variable that contains the text but it does not work.

    so my question is: how do i get these breaks in the text, so that the text
    looks
    good in the layer?.

    here is my code:
    +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++
    function toonSpelregels( spel){
    if(spel == 'zappen'){
    document.getEle mentById('spelr egels').style.v isibility =
    'visible';
    verkort = document.getEle mentById('spelr egels').childNo des[0];
    uitleg="blabla. ......." + "<br><br>" + " blabla....";
    verkort.nodeVal ue=uitleg;
    }

    .............
    .............
    }

    <div id="spelregels" >
    </div>
    +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++

    thanks,

    fjodor





  • Lasse Reichstein Nielsen

    #2
    Re: how to place a &lt;br&gt; in a javascriptfunct ion?

    "Fjodor Klondyke" <fjodor_klondyk e@hotmail.com> writes:
    [color=blue]
    > i have a function in javascript. when someone clicks on a link the text in a
    > layer changes.
    > i want breaks in the text, in html you would use '<br><br>'.
    > i tried this in the variable that contains the text but it does not work.
    >
    > so my question is: how do i get these breaks in the text, so that
    > the text looks good in the layer?.[/color]

    You use br elements.
    Plain text has no formatting, so if you want formatting, you need to add
    more than just plain text.


    var verkort = document.getEle mentById('spelr egels');
    verkort.style.v isibility="visi ble";
    // clear verkort
    while (verkort.hasChi ldNodes()) {
    verkort.removeC hild(verkort.la stChild);
    }
    //insert new nodes
    verkort.appendC hild(document.c reateTextNode(" blabla.......") );
    verkort.appendC hild(document.c reateElement("b r"));
    verkort.appendC hild(document.c reateElement("b r"));
    verkort.appendC hild(document.c reateTextNode(" blabal...."));

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • HikksNotAtHome

      #3
      Re: how to place a &lt;br&gt; in a javascriptfunct ion?

      In article <bghi28$rm3$1@r eader11.wxs.nl> , "Fjodor Klondyke"
      <fjodor_klondyk e@hotmail.com> writes:
      [color=blue]
      >i have a function in javascript. when someone clicks on a link the text in a
      >layer changes.
      >i want breaks in the text, in html you would use '<br>'.
      >i tried this in the variable that contains the text but it does not work.[/color]

      \n is a new line in javascript text.
      --
      Randy
      All code posted is dependent upon the viewing browser
      supporting the methods called, and Javascript being enabled.

      Comment

      Working...