mirror of https://github.com/searxng/searxng
[mod] the search text input gets the focus automatically
parent
04727a2043
commit
4e8b75a0fb
@ -0,0 +1,27 @@
|
|||||||
|
(function (w, d) {
|
||||||
|
'use strict';
|
||||||
|
function addListener(el, type, fn) {
|
||||||
|
if (el.addEventListener) {
|
||||||
|
el.addEventListener(type, fn, false);
|
||||||
|
} else {
|
||||||
|
el.attachEvent('on' + type, fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function placeCursorAtEnd() {
|
||||||
|
if (this.setSelectionRange) {
|
||||||
|
var len = this.value.length * 2;
|
||||||
|
this.setSelectionRange(len, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addListener(w, 'load', function () {
|
||||||
|
var qinput = d.getElementById('q');
|
||||||
|
if (qinput !== null) {
|
||||||
|
addListener(qinput, 'focus', placeCursorAtEnd);
|
||||||
|
qinput.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})(window, document);
|
||||||
|
|
Loading…
Reference in New Issue