Author |
Topic |
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 11 December 2014 : 12:29:35
|
Can this be modified to put the cursor between the tags instead of after them? I'm very javascript challenged.
function bold() {
var text = getText();
if (helpstat) {
alert("Bold Tag Makes the enclosed text bold.\n\nUSE: This is some bold text");
} else if (basic) {
AddTxt="" + text + "";
AddText(AddTxt);
} else {
if (text) {
txt=prompt("Text to be made BOLD.",text);
} else {
txt=prompt("Text to be made BOLD.","Text");
}
if (txt!=null) {
AddTxt=""+txt+"";
AddText(AddTxt);
}
}
}
|
Switch the order of your title tags |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 11 December 2014 : 13:39:39
|
Yeah, never has using any browser since I installed the forum almost 10 years ago.
I get asked about it all the time, mainly from mobile users, I've just never pursued it until now. |
Switch the order of your title tags |
|
|
bobby131313
Senior Member
USA
1163 Posts |
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 11 December 2014 : 14:18:58
|
I see what you're saying now, it's not the code I posted. Seems I replaced this once in 2008 by my notes for a "Firefox Jump" bug that I don't remember. |
Switch the order of your title tags |
|
|
bobby131313
Senior Member
USA
1163 Posts |
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 12 December 2014 : 21:13:57
|
Had some help, this works perfectly for me.... Your mileage may vary...
function AddText(text) {
var crtScrollTop;
var crtScrollLeft;
try {
var tarea = document.PostTopic.Message;
if (typeof tarea.scrollTop != 'undefined') {
crtScrollTop = tarea.scrollTop;
crtScrollLeft = tarea.scrollLeft;
}
} catch (e) {};
var tarea = document.PostTopic.Message;
if (typeof tarea.selectionStart != 'undefined')
{ // if it supports DOM2
start = tarea.selectionStart;
end = tarea.selectionEnd;
tarea.value = tarea.value.substr(0,tarea.selectionStart)
+ text + tarea.value.substr(tarea.selectionEnd);
tarea.focus();
if (start === end )
{
res = text.split("/");
if (res.length > 1)
{
tarea.selectionStart = start + (text.length) / 2;
tarea.selectionEnd = tarea.selectionStart;
}
}
else
{
tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
tarea.selectionEnd = start + text.length;
}
}
else
{
if (tarea.createTextRange && tarea.caretPos) {
var caretPos = tarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else {
tarea.value += text;
}
tarea.focus(caretPos);
}
try {
var tarea = document.PostTopic.Message;
if (typeof tarea.scrollTop != 'undefined') {
tarea.scrollTop = crtScrollTop;
tarea.scrollLeft = crtScrollLeft;
}
} catch (e) {};
}
|
Switch the order of your title tags |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 13 December 2014 : 13:23:04
|
Cool, it has the "Jump" fix incorporated from 2008 also.
Ironically, back then it was FF doing it, now it's Chrome. |
Switch the order of your title tags |
|
|
|
Topic |
|