下面的className变化的onfocus IE7 DROPDOWNLIST不显示在1日点击 [英] IE7 Dropdownlist not displaying on 1st click following className change onfocus

查看:107
本文介绍了下面的className变化的onfocus IE7 DROPDOWNLIST不显示在1日点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变CSS类一个DropDownList就其onfocus事件来改变它的背景色。

I am trying to change the CSS class of a dropdownlist on its onfocus event to change its background colour.

在上DropDownList的用户点击,CSS类发生改变(backgound颜色发生改变),但不显示的选项列表,直到再次单击。

When the user clicks on the the dropdownlist, the CSS class is changed (the backgound colour is changed), but the list of options is not displayed until it is clicked again.

这是发生在IE7。它在Firefox正常工作。

This is happening in IE7. It works fine in Firefox.

我已经随处可见对这个问题的唯一意见认为还使用onfocusin事件:

The only advice I have found anywhere on this problem suggests also using the onfocusin event:

<一个href=\"http://www.eggheadcafe.com/software/aspnet/34297064/open-dropdown-list-only-with-double-mouse-click.aspx\" rel=\"nofollow\">http://www.eggheadcafe.com/software/aspnet/34297064/open-dropdown-list-only-with-double-mouse-click.aspx

但没有任何效果。

onfocus事件附加到后面的code DropDownList的:

The onfocus event is attached to the dropdownlist in the code behind:

ddl.Attributes.Add("onfocus", "setCssClass();");

JavaScript的集合类:

The javascript the sets the class:

ddl.className = "Class1";

请帮帮忙!

推荐答案

感谢任何人谁看了这一点,但我已经找到自己的答案。

Thanks to anybody who looked at this, but I have found the answer myself.

当焦点是从一些特殊管制来的问题只是存在的。这些控制了的onblur事件还设置类的下拉的。

The problem was only occuring when the focus was coming from a few particular controls. These controls had onblur events that also set the class of the dropdown.

我认为这些事件的onblur在会前的onfocus运行/ onfocusin,但似乎这是情况并非如此。该事件的onblur然后似乎应用类变化时关闭DropDownList的。

I had assumed that these onblur events would run before the onfocus/onfocusin, but it seems that this is not the case. The onblur events then seem to close the dropdownlist when applying the class change.

反正我现在检查哪个控件具有的onblur事件的焦点就这些了,如果是下拉列表中,我不运行的onblur内的主要逻辑和现在都按预期工作。

Anyway, I now check which control has the focus on these onblur events, and if it is the dropdown list, I don't run the main logic within the onblur and all now works as expected.

这篇关于下面的className变化的onfocus IE7 DROPDOWNLIST不显示在1日点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆