简体   繁体   English

IE引起文本框焦点模糊

[英]IE raises blur on focus in textbox

First of all, this is my first question here, sorry if it is not asked properly. 首先,这是我在这里的第一个问题,对不起,如果没有正确回答。 I have a bug in a web app we developed in the office. 我在办公室开发的网络应用程序中存在错误。 The app is nearly done but In IE < 9 it happens that a text-box which has focus and blur events attached with jQuery raises the blur event as soon as you click on it. 该应用程序即将完成,但是在IE <9中,碰巧一个文本框带有焦点和模糊事件,而jQuery附带了该文本框,一旦您单击它就会引发模糊事件。 You can see this in this picture (just clicked in the text-box): 您可以在这张图片中看到它(只需在文本框中单击):

https://www.dropbox.com/s/yn10xfrfxsr38bq/screen.PNG https://www.dropbox.com/s/yn10xfrfxsr38bq/screen.PNG

$('#divVolee [type="text"]') 

has no focusin or focus events attached. 没有附加聚焦或聚焦事件。

The URL to the application: 应用程序的URL:

http://86.126.255.70:2213/Anoxa/

If you want you can enter using the "Demarrer" button. 如果需要,可以使用“ Demarrer”按钮输入。

I do not ask anybody to write code for me or anything like that, I just don't know after days of searching in the code and on the net what could cause that. 我不要求任何人为我或类似的人编写代码,我只是不知道在代码和网络上搜索了几天之后会导致什么。

I tried focusin, focus, focusout, blur, attaching directly or using delegates, the same thing. 我尝试过聚焦,聚焦,聚焦,模糊,直接附加或使用委托进行同一操作。 As soon as I click in the input field it raises the blur / focusout event. 一旦我在输入字段中单击,就会引发模糊/聚焦事件。

Thank you for your help. 谢谢您的帮助。

I found it. 我找到了。 I started to comment everything out until I found the culprit: 我开始评论所有内容,直到找到罪魁祸首:

function resizeAccordion() {
    var active = $('#divAccordion').accordion('option', 'active');
    $('#divAccordion').accordion('destroy').accordion({ heightStyle: "fill", active:   active });
}

 var resizeId;
 $(window).resize(function () {
     clearTimeout(resizeId);
     resizeId = setTimeout(resizeAccordion, 600);
 });

This code was supposed to re-size and re arrange the accordion in the page if the user re-sized the browser. 如果用户调整了浏览器的大小,则应使用此代码调整页面中的手风琴大小并重新排列。 Somehow in IE<9 it got triggered without reason and this caused the blur event to be triggered. 在IE <9中以某种方式它被无故触发,这导致了模糊事件被触发。 After so many hours. 经过这么几个小时。 Maybe it is may thinking or code that was wrong, but i still hate IE for it. 也许是思维或代码错误,但我仍然讨厌IE。

I cannot reproduce this bug (using IE8 mode under IE9). 我无法重现此错误(在IE9下使用IE8模式)。 But a simple workaround could be: (even quite weird) 但是一个简单的解决方法可能是:(甚至很奇怪)

$('#divVolee [type="text"]').focus(function(){
    //>>code for FOCUS here<<
    $(this).blur(blurcallback);
});

function blurcallback()
{
  //>>code for BLUR here<<
  $(this).off('blur');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM