<html>
<body>
<script type="text/javascript">
function Check()
{
var t = document.getElementById('t');
alert(t.textContent);
t.textContent = 'blah';
}
</script>
<textarea name="t" id="t"></textarea>
<a href="javascript:Check();">Check</a>
</body>
</html>
Load the page in FF, click on "check", everything works as expected :
the alert box is empty then "blah" is shown in the textarea.
Then delete a character in the textarea (say, the letter "h") and
click again on "check" :
1) the alert incorrectly shows "blah" instead of "bla".
2) it then should replace the contents of the textarea with "blah",
but it doesn't.
From then on, whatever you do, including refreshing the page, it won't
work as expected. Placing the script below the textarea declaration
doesn't change a thing.
So what's wrong : my expectations, my syntax, FF's textarea/
textContent handling or FF's javascript handling ? Any workarounds ?
Thanks !
Michel
Before click: ...<textarea name="t" id="t"></textarea>...
After click: ...<textarea name="t" id="t">blah</textarea>...
textContent returns the text content in the DOM - not the current
value of the
control; You probably want t.value in this case.
http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent
</quote>
Hope this helps those trying to solve the "textContent vs innerText"
problem.
Michel
> > Michel- Hide quoted text -
>
> - Show quoted text -