Hov, der manglede lidt:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Indsæt smiley</title>
<script type="text/javascript">
function emoticon(text, formnavn, inputnavn) {
var frm = document.forms[formnavn];
var elem = frm.elements[inputnavn];
text = ' ' + text + ' ';
if (elem.createTextRange && frm.message.caretPos) {
var caretPos = elem.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
elem.focus();
} else {
elem.value += text;
elem.focus();
}
}
function storeCaret_post(textEl) {
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
</script>
</head>
<body>
<form name="minform" action="#" method="post">
<textarea name="tekst" id="message" onSelect="storeCaret_post(this);" onClick="storeCaret_post(this);" onKeyUp="storeCaret_post(this);"></textarea>
<input type="button" name="knap" value="Button" onClick="java script:emoticon(';-)', 'minform', 'tekst')">
</form>
</body>
</html>