Hi,
When clicking the smilie images to insert the code automatically into posts (and the other markup), the code is forced to the bottom of the message no matter where your cursor is.
I think it would be better to insert the code at the cursors position.
This code should do that:
{
if (html.createTextRange)
html.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (text) {
if (document.Sign.html.caretPos)
{
var caretPos = document.Sign.html.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else
alert("You must click in the text area before you can insert html");
}
.......then you want something like:
When clicking the smilie images to insert the code automatically into posts (and the other markup), the code is forced to the bottom of the message no matter where your cursor is.
I think it would be better to insert the code at the cursors position.
This code should do that:
Code:
function storeCaret (html) {
if (html.createTextRange)
html.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (text) {
if (document.Sign.html.caretPos)
{
var caretPos = document.Sign.html.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else
alert("You must click in the text area before you can insert html");
}
.......then you want something like:
Code:
<input type="button" onclick="insertAtCaret(' ');" value="Bold">