PDA

View Full Version : document.writeIn()


xSKATEx
01-29-2004, 08:07 PM
Alright.......I recently found out the use of document.writeIn().....How do I get the document.writeIn() to add to my page(not delete everything and just show my document.writeIn()), kind of like a running tally.

n8thegreat
01-29-2004, 08:42 PM
use document.write()

Willy Duitt
01-30-2004, 12:06 AM
Originally posted by xSKATEx
Alright.......I recently found out the use of document.writeIn().....How do I get the document.writeIn() to add to my page(not delete everything and just show my document.writeIn()), kind of like a running tally.

Firstly; it's document.writeln (small L)
As in WRITE LINE ;)

Not document.writeIn (uppercase i)
As in WRITE IN :eek:

Secondly; both document.writeln and document.write will overwrite the document if invoked after the document has been loaded. What I think you are looking for is either, innerText which is IE proprietary or innerHTML which is supported by IE5+ and NS6+.

More info on writeln can be found here (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/writeln.asp).

.....Willy

Jon Hanlon
01-30-2004, 08:07 PM
In IE you can use the insertAdjacentHTML() (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/insertadjacenthtml.asp) method, but generally you just whack a span at the end of your document and use the innerHTML (http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp) property which is common to both IE and Netscape 6+.


<button onclick="appendText()">Click Me</button>
<span id="eof"></span>
</body>
</html>

<script language="Javascript">
function appendText() {
var eof = document.getElementById("eof");
eof.innerHTML += "<br><i>Another</i> line of content";
}
</script>


BTW, the only difference between document.write() and document.writeln() is that the latter adds a line-feed to the end of the line (for better readability).

xSKATEx
02-04-2004, 08:52 PM
thx!