Answer the question
In order to leave comments, you need to log in
How to make a photo upload anywhere in the text in a textarea?
How can I make sure that when uploading an image to the site, an img tag with a link to this image is inserted into the textarea, as it is presented on the toaster? Throw some lesson or code. Thank you.
Answer the question
In order to leave comments, you need to log in
I can assume that you need to "determine" the location of the mouse cursor in the text field.
function getCursorPosition( ctrl ) {
var CaretPos = 0;
if ( document.selection ) {
ctrl.focus ();
var Sel = document.selection.createRange();
Sel.moveStart ('character', -ctrl.value.length);
CaretPos = Sel.text.length;
} else if ( ctrl.selectionStart || ctrl.selectionStart == '0' ) {
CaretPos = ctrl.selectionStart;
}
return CaretPos;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question