Нашёл то что искал , но там вылазит {auto}
undefined Как убрать ? undefined эту надпись ?
<script>
function tag (obj, pre, after)
{
if (document.selection)
with (document.selection.createRange ()) {text = pre + text + after}
else if (obj.selectionStart)
with (obj)
{
var t = scrollTop, l = scrollLeft, txt = obj.value,
st = selectionStart, ln = selectionEnd - st; focus ();
value = txt.substr (0, st) + pre + txt.substr (st, ln) + after + txt.substr (st + ln);
selectionStart = selectionEnd = st; scrollTop = t; scrollLeft = l;
}
else
obj.value += pre + after;
}
</script>
<textarea wrap="off" id="txa" rows="10" cols="40"></textarea>
<a href=#" onclick="tag (document.getElementById ('txa'), '{auto}');">Машина</a></th>
<a href=#" onclick="tag (document.getElementById ('txa'), '{moto}');">Мото</a></th>
<a href=#" onclick="tag (document.getElementById ('txa'), '{robot}');">Робот</a></th>
<a href=#" onclick="tag (document.getElementById ('txa'), '{home}');">Дом</a></th>