How to write messages to the screen without using "document.write()"?

Q

How to write messages to the screen without using "document.write()"?

✍: Guest

A

Changing the contents of an element is a much better solution. When the method showStatus is invoked, it will change the content of the span.
...
function showStatus(message) {
var element = document.getElementById("mystatus");
element.textContent = message; //for Firefox
element.innerHTML = message; //for IE
return true;
}
...
<span id="mystatus">Test. </span>
...

2011-02-15, 4072👍, 0💬