By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

<br> not interpretered but just rendered.

P: n/a
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 <brthe <brwill 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>
Jul 14 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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 <brthe <brwill 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('every one'));
But I guess what you want is to se the innerHTML:
omschrijving.firstChild.innerHTML=newdescription;

Good luck,
Vincent
Jul 14 '06 #2

P: n/a
you might try to close it properly....<br />

Jul 14 '06 #3

P: n/a
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

Jul 14 '06 #4

P: n/a
Sevinfooter wrote:
you might try to close it properly....<br />
He said "a HTML line-break" so <br(or <BR>) is "properly".

Richard.

Jul 14 '06 #5

P: n/a
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.
On 14 Jul 2006 09:29:52 -0700, "Sevinfooter" <ma**********@gmail.com>
wrote:
>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
Jul 22 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.