473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.getElementById('spelregels').style.visibi lity =
'visible';
verkort = document.getElementById('spelregels').childNodes[0];
uitleg="blabla........" + "<br><br>" + " blabla....";
verkort.nodeValue=uitleg;
}

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

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

thanks,

fjodor

Jul 20 '05 #1
2 5597
"Fjodor Klondyke" <fj*************@hotmail.com> writes:
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?.


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.getElementById('spelregels');
verkort.style.visibility="visible";
// clear verkort
while (verkort.hasChildNodes()) {
verkort.removeChild(verkort.lastChild);
}
//insert new nodes
verkort.appendChild(document.createTextNode("blabl a......."));
verkort.appendChild(document.createElement("br"));
verkort.appendChild(document.createElement("br"));
verkort.appendChild(document.createTextNode("blaba l...."));

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In article <bg**********@reader11.wxs.nl>, "Fjodor Klondyke"
<fj*************@hotmail.com> writes:
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.


\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.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: fis | last post by:
Hi all, I've problem because there are needed break lines in my texts on the web site but i can't do it :( My pipeline looks like: XMS -> I18N -> XSLT -> HTML I have lot of texts in my...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
7
by: noor.rahman | last post by:
I have an XML file that stores data from an HTML form. I use XSL to display the data in HTML format. The data may have newline characters. However, XSL is not displaying the newlines properly in...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
2
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
1
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
9
by: Wayne | last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test $p = str_replace ("%0D%0A", "<br>", $a); That is the above code that I am using, however, it is not picking up the CR/LF from the textarea. I...
2
by: xhe | last post by:
I met a very headache problem in javascript, I think this might be difference between IE and NS / Safari. I have a text area <form> <textarea name='tex1' onkeyup='displayit();'></textarea>...
7
by: Nathan Sokalski | last post by:
Something that I recently noticed in IE6 (I don't know whether it is true for other browsers or versions of IE) is that it renders <br/and <br></br> differently. With the <br/version, which is what...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.