Form input loses focus on scrollbar in IE

Hope someone can help me. I know this was discussed here , but this example is a prototype and a stranger to me. I am looking for a strict javascript or jquery solution. I have an example setup here . Click on the scroll bar in FF and you will not get a warning, but click on it in IE and you will. Please help me, thanks!

+4
source share
2 answers

After some searching, I came up with this answer . As far as I know, you cannot actually cancel the blur event, nor can you trigger the focus event at the same time. This is what I do not understand. You can blur the focus, but you cannot focus on the blur. In any case, my solution uses the setTimeout function to trigger a 1 ms focus event after losing focus.

var o = this; oTimeout = setTimeout(function(){ o.focus(); },1); 

Using mouseenter and mouseleave events, I set a boolean to refer to the blur event

 $("div#box").mouseenter(function(){ changeFocus(1); }).mouseleave(function(){ changeFocus(0); }); 
+5
source

I had the same problem and it works for what she needs. Just set the focus back to the element.

 $('#divWithScrollBar').scroll( function () { $('#elementThatLosesFocus').focus(); }); 

This event somehow fires after the element is blurred, but before the onblur event is clicked. It didn’t actually look, but it looks like it’s happening.

Scrolling seems a little slow, but it works.

IE owes me many hours of my life.

+5
source

Source: https://habr.com/ru/post/1301633/


All Articles