Entry
How can I use javascript to change text in a document that is already loaded?
May 17th, 2001 05:53
Colin Fraser, Eric Sanders,
Try this
<SCRIPT LANGUAGE="JavaScript">
function rewrite() {
document.all("ONE").innerText = 'This is new text in SPAN ONE';
document.all("TWO").innerText = 'This is new text in SPAN TWO';
}
function rewrite2() {
document.all("ONE").innerText = 'This is the original text in SPAN
ONE';
document.all("TWO").innerText = 'This is the original text in SPAN
TWO';
}
</SCRIPT>
<p>
<SPAN ID="ONE">This is the current text in SPAN ONE</SPAN>
<br>
<SPAN ID="TWO">This is the current text in SPAN TWO</SPAN>
<p>
<FORM>
<INPUT TYPE="BUTTON" VALUE="Change Text" onClick="rewrite()">
<INPUT TYPE="BUTTON" VALUE="Change Back" onClick="rewrite2()">
</FORM>
This works in IE5.5 but not NN4.7.