JavaScript - Createtextnode
Hello, I'm working on a textarea box and I'm wanting to make it so when a user clicks on a link a BB tags much like what you see here will appear right after all of the text you just typed in. So it would be the exact same as if you were typing on this forum and asking a question and you went to the top and clicked the Wrap [PHP] tag and out comes the tags right where your pointer is at. So I got this to work just fine on IE but oddly enough it isn't working the same on net scape browsers.
http://idigteck.com/mess.php Try it out for yourself and see what I mean. Note you have to type in some text for it to mess up. I tried different ways of doing this and non work so far. What am I doing wrong here? Code: <script type="text/javascript"> function appendTag(eid) { var txtArea = document.getElementById('txtArea'); var bbtags = new Array('', ''); var aTag = document.createTextNode(bbtags[0]); txtArea.appendChild(aTag); } </script> Similar Tutorialsnot sure anything wrong with my IE8 browser or 'createTextNode' method. here comes the bug: if you directly do this document.body.appendChild(document.createTextNode(" "+"a")), then there won't be any spaces before 'a' however, if the argument of that method is changed to "a"+" "+"a", this time it will be ok. why it cannot create the leading spaces before any non-whitespace string? thx in advance. |