Tab: scroll to original position in Firefox
This commit is contained in:
parent
5e189f68e2
commit
b0fe26ba3e
|
@ -170,14 +170,17 @@ function textareaKeydown(target, event, tab, button) {
|
||||||
// inspired by http://pallieter.org/Projects/insertTab/
|
// inspired by http://pallieter.org/Projects/insertTab/
|
||||||
if (target.setSelectionRange) {
|
if (target.setSelectionRange) {
|
||||||
var start = target.selectionStart;
|
var start = target.selectionStart;
|
||||||
|
var scrolled = target.scrollTop;
|
||||||
target.value = target.value.substr(0, start) + '\t' + target.value.substr(target.selectionEnd);
|
target.value = target.value.substr(0, start) + '\t' + target.value.substr(target.selectionEnd);
|
||||||
target.setSelectionRange(start + 1, start + 1);
|
target.setSelectionRange(start + 1, start + 1);
|
||||||
|
target.scrollTop = scrolled;
|
||||||
return false; //! still loses focus in Opera, can be solved by handling onblur
|
return false; //! still loses focus in Opera, can be solved by handling onblur
|
||||||
} else if (target.createTextRange) {
|
} else if (target.createTextRange) {
|
||||||
document.selection.createRange().text = '\t';
|
document.selection.createRange().text = '\t';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (event.keyCode == 27) {
|
}
|
||||||
|
if (event.keyCode == 27) {
|
||||||
var els = target.form.elements;
|
var els = target.form.elements;
|
||||||
for (var i=1; i < els.length; i++) {
|
for (var i=1; i < els.length; i++) {
|
||||||
if (els[i-1] == target) {
|
if (els[i-1] == target) {
|
||||||
|
|
Loading…
Reference in a new issue