473,387 Members | 1,766 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,387 software developers and data experts.

it did not work

<div id="textHolder"></div>
<input type="button" value="Add some text" onclick="
addText( 'Here is some text', 'textHolder' );
">
<script type="text/javascript">
function addText( str, elID ){
var aDiv = document.getElementById( elID );
var oTxt = document.createTextNode( str );
aDiv.appendChild( str );
}
</script>

Ok... I tryed it with html in the string but when I looked at the page
it just showed the text
and it did not parse any of it as html. How do I get it do do this?

Aug 6 '05 #1
3 1338
greenflame wrote:
function addText( str, elID ){
var aDiv = document.getElementById( elID );
var oTxt = document.createTextNode( str );
aDiv.appendChild( str );


That line should be:
aDiv.appendChild(oTxt);

--
Isofarro.
FAQ: http://www.html-faq.com/
isolani: http://www.isolani.co.uk/blog/
Aug 6 '05 #2
O yea I noticed that so i changed it. sorry for not mentioning it. But
it still does not show the html. :(

Aug 6 '05 #3
greenflame wrote:
<div id="textHolder"></div>
<input type="button" value="Add some text" onclick="
addText( 'Here is some text', 'textHolder' );
">
<script type="text/javascript">
function addText( str, elID ){
var aDiv = document.getElementById( elID );
This line looks for a div with an id of elID.
var oTxt = document.createTextNode( str );
Then a text node is created with the text in str
aDiv.appendChild( str );
And then the text node is appended to the div. All there is to 'see'
is the text - 'Here is some text'.

[...]

Ok... I tryed it with html in the string but when I looked at the page
it just showed the text
and it did not parse any of it as html. How do I get it do do this?


There is no HTML to parse. You are using DOM methods to create
elements, not HTML.

If you want a tutorial, go through the stuff at w3schools:

<URL:http://www.w3schools.com/htmldom/default.asp>

It's a bit old and IE centric, but it will get you started. Also
check through the archives here to find things you are after and read
the FAQ.

<URL:http://www.jibbering.com/faq/>

If you want to see the content of the page after you've done your DOM
stuff, read the thread here:

<URL:http://groups-beta.google.com/group/comp.lang.javascript/browse_thread/thread/a108f8cb58111ece/d6a776db34c1be8d?q=innerHTML+view+document&rnum=4& hl=en#d6a776db34c1be8d>

--
Rob
Aug 7 '05 #4

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

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
3
by: Douglas Buchanan | last post by:
Buttons don't work if form is opened on startup A2k If 'frmMain' is set to open by default at startup none of the buttons work. If 'frmMain' is opened from the database window then all the...
15
by: Brett | last post by:
I'd like to know what management and the work environment are like where you work. I need something relative to compare my current work environment. Here's a few questions I have: 1.) Is it...
2
by: Holysmoke | last post by:
Hi, I have a asp.net form with a button in it. In the onlclick event of button I want to write a function which does some a bit of work with a timespan of 15 seconds. So I want to show a image...
1
by: Jeff | last post by:
Hello, I have developed a library of controls but for the life of me cannot get ToolboxBitmapAttribute to work -- my image simply will not display in the toolbox of any project using my...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
48
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) *...
33
by: bonk | last post by:
I have an application that needs to perform some background work, i.e. Logging, wich must not block the main thread. How would I basically design such a scenario? It is obvious that I should do...
11
Niheel
by: Niheel | last post by:
http://bytes.com/images/howtos/information_overloaded.jpgPaul Graham wrote an interesting article a few months back about how the internet is leading to information overload for information workers...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.