Sami Posted December 29, 2010 Share Posted December 29, 2010 <!DOCTYPE html><html><head><title></title></head><body><div><button onclick="alert(document.getElementById('input').innerHTML);">Alert</button></div><textarea id="input" onchange="document.getElementById('display').innerHTML=this.innerHTML;" onkeyup="document.getElementById('display').innerHTML=this.innerHTML;" style="display:block;width:100%;"></textarea><div id="display" style="border:solid 1px black;">The HTML is supposed to appear here.</div></body></html> It works in IE(Tab), but when I try it in Firefox and Opera, guess what...Firefox:IE(Tab): Link to comment Share on other sites More sharing options...
ShadowMage Posted December 29, 2010 Share Posted December 29, 2010 I think textareas are an exception to the typical rules. They don't use innerHTML, try using value. Link to comment Share on other sites More sharing options...
jeffman Posted December 29, 2010 Share Posted December 29, 2010 Yeah, this question comes up a lot. And the confusion is not helped by the fact that some browsers do in fact let you use innerHTML instead of the value property. Link to comment Share on other sites More sharing options...
Sami Posted January 3, 2011 Author Share Posted January 3, 2011 Now it shows up in firefox after the textbox looses focus, and disapears if I'm trying to write again.I'd like it to show up while I write! Link to comment Share on other sites More sharing options...
ShadowMage Posted January 4, 2011 Share Posted January 4, 2011 Now it shows up in firefox after the textbox looses focus, and disapears if I'm trying to write again.I'd like it to show up while I write!Can you show us the new code? Link to comment Share on other sites More sharing options...
Sami Posted January 10, 2011 Author Share Posted January 10, 2011 <!DOCTYPE html><html><head><title></title></head><body><div><button onclick="alert(document.getElementById('input').value);">Alert</button></div><textarea id="input" onchange="document.getElementById('display').innerHTML=this.value;" onkeyup="document.getElementById('display').innerHTML=this.innerHTML;" style="display:block;width:100%;"></textarea><div id="display" style="border:solid 1px black;">The HTML is supposed to appear here.</div></body></html> Link to comment Share on other sites More sharing options...
ShadowMage Posted January 10, 2011 Share Posted January 10, 2011 You changed the onchange event but not the onkeyup event. Change that to also use this.value and it should work. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.