Non-DOM Compliant innerHTML / innerText*

innerHTML will work with IE5+ and Netscape 6
* innerText will work with IE5+. IT DOES NOT WORK WITH NETSCAPE 6+.

For the DOM-Compliant version, click here
The Netscape 4 equivalent can be found at "Writing into Layers" by Peter-Paul Koch.

<div id="test1">
</div>

We're going to place content into the div id="test1" using document.getElementById('test1').innerHTML and document.getElementById('test1').innerText in the form below.

innerHTML

innerText

<form name="form1">
<span class="title">innerHTML</span> <br>
<textarea name="innerhtmlTest" rows="10">
</textarea>
<br>
<input type="button" onclick="document.getElementById('test1').innerHTML=document.form1.innerhtmlTest.value"  value="innerHTML">

<span class="title">innerText</span> <br>
<textarea name="innertextTest"  rows="10">
</textarea>
<br>
<input type="button" onclick="document.getElementById('test1').innerText=document.form1.innertextTest.value"  value="innerText">
</form>		

As you can see, setting the innerHTML or innerText of an object fairly simple. You can put innerText and innerHTML into almost any item such as td, p, or div tags. See Dynamic Records Display Using innerHTML for an example of what can be done using innerHTML and arrays.







PXL8 2003