<br> not interpretered but just rendered.

L

Louis.

Hello,

If the user clicks a link in my webpage then a text gets updated.
However, one text is too long and I need to put a HTML line-break into
it. When I stick in a <br> the <br> will simply appear in the web
page. I have no idea how to make the browser interpret the <br>.

I know there is a workaround solution by putting the text in a
invisible table cell. However, then I cannot set where the lines
break.

I hope somebody can help me.

TIA,
Louis.


<script language="Javascript">
function ChangeText(card) {
if (card=='01') { document.werk.src='images/s01.jpg'; var
newdescription="Nice card."; }
if (card=='02') { document.werk.src='images/s02.jpg'; var
newdescription="This card is special, it comes in various sizes and
various colours.<br>There is also an envelloppe available for this
card."; }
var omschrijving = document.getElementById("omschrijving");
omschrijving.firstChild.nodeValue=newdescription;
}
</script>
 
V

Vincent van Beveren

If the user clicks a link in my webpage then a text gets updated.
However, one text is too long and I need to put a HTML line-break into
it. When I stick in a <br> the <br> will simply appear in the web
page. I have no idea how to make the browser interpret the <br>. ....
<script language="Javascript">
function ChangeText(card) {
if (card=='01') { document.werk.src='images/s01.jpg'; var
newdescription="Nice card."; }
if (card=='02') { document.werk.src='images/s02.jpg'; var
newdescription="This card is special, it comes in various sizes and
various colours.<br>There is also an envelloppe available for this
card."; }
var omschrijving = document.getElementById("omschrijving");
omschrijving.firstChild.nodeValue=newdescription;
}
</script>


Hi Louis,

Why don't you let your browser calculate where the line-break should be
placed? Anyway, line-breaks should be inserted in the same way as the
rest of DOM:

element.appendChild(document.createTextNode('Hello'));
element.appendChild(document.createElement('br'));
element.appendChild(document.createTextNode('everyone'));


But I guess what you want is to se the innerHTML:
omschrijving.firstChild.innerHTML=newdescription;

Good luck,
Vincent
 
S

Sevinfooter

like vincent said, you might want to let the browser decide where to
break it. if its a huge issue, you want to use css to limit the width
of the element in which that text is going to be placed. if you posted
some html it might be easier to help with a solution
 
L

Louis.

Thank you everyone.

The suggestion of Vincent I could not get to work, because I lack the
understanding in this area. The <br /> did not work.

I ended up placing the text in a table cell.

Louis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top