|
|
Re: Cursor focus after formatting text in Firefox [message #33991 is a reply to message #33954] |
Sat, 30 September 2006 19:05   |
|
Make a long post (one that forces your edit window to scroll) - Then go somewhere in the middle, highlight a word, make it bold - observe that the scrollwindow will move to the top, and your cursor will move to the end of the text. Perhaps it's a firefox setting, but many of my users experience the same problem. (I have the same problem in phpBB boards as well, but the problem does not occur when using those fancy java WYSBLAH editors.)
Ginnunga Gaming
|
|
|
|
|
|
|
Re: Cursor focus after formatting text in Firefox [message #34800 is a reply to message #33954] |
Sat, 18 November 2006 05:06   |
|
Here is a fix (copy pasted from the internet):
Url for the format
<a href="javascript:void(0);" onclick="surroundText('[b]', '[/b]', document.post_form.msg_body); return false;">
function surroundText(text1, text2, textarea)
{
// Can a text range be created?
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
{
var caretPos = textarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
caretPos.select();
}
// Mozilla text range wrap.
else if (typeof(textarea.selectionStart) != "undefined")
{
var begin = textarea.value.substr(0, textarea.selectionStart);
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
var end = textarea.value.substr(textarea.selectionEnd);
var newCursorPos = textarea.selectionStart;
var scrollPos = textarea.scrollTop;
textarea.value = begin + text1 + selection + text2 + end;
if (textarea.setSelectionRange)
{
if (selection.length == 0)
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
else
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
textarea.focus();
}
textarea.scrollTop = scrollPos;
}
// Just put them on the end, then.
else
{
textarea.value += text1 + text2;
textarea.focus(textarea.value.length - 1);
}
}
Ginnunga Gaming
|
|
|
|
|
|