IE Bug:使用< optgroup>时未调用onchange事件在选择下拉列表中 [英] IE Bug: onchange event not called when using <optgroup> in select drop-down

查看:87
本文介绍了IE Bug:使用< optgroup>时未调用onchange事件在选择下拉列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在< select>中下拉时,当使用鼠标滚轮滚动下拉菜单并且在新的< optgroup>上穿越

时,不会调用onchange事件。


使用下面的例子,注意当鼠标滚轮在A3和B1之间滚动时,如何调用onchange事件

,但是它正常工作
在A1和A2之间滚动时



例如

----------------- -------------------------

< html>

< body onload = " document.forms [''myForm'']。elements [''mySelect'']。focus()">


< form name =" myForm" id =" myForm">

< select onchange =" alert(''onchange event'');" name =" mySelect"

id =" mySelect">

< optgroup label =" A组">

< option value =" A1"> A1< / option>

< option value =" A2"> A2< / option>

<选项值=" A3"> A3< / option>

< / optgroup>

< optgroup label =" B组">

< option value =" B1"> B1< / option>

< option value =" B2"> B2< / option>

< option value =" B3"> B3< / option>

< / optgroup>

< optgroup label =" C组" >

< option value =" C1"> C1< / option>

< option value =" C2"> C2< / option>

< option value =" C3"> C3< / option>

< / optgroup>

< / select>

< / form>


< / body>

< / html>
------------------------------------------


谢谢,

Ryan McGeary

解决方案

文章< d5 * ************************@posting.google.com> ,
ry*********@hotmail.com (Ryan McGeary)写道:

在< select>中下拉时,当使用鼠标滚轮滚动下拉菜单并在新的< optgroup>上穿越
时,不会调用onchange事件。


也不应该。 onchange事件不应该触发,直到选择了另一个选项

(选项组不是选项)。

使用下面的例子,注意onchange事件是如何被调用的
当鼠标滚轮在A3和B1之间滚动时,但在A1和A2之间滚动时它可以正常工作。




我得到的唯一方法是在我选择不同的

选项并离开选择列表之后,警告该代码。应该如此。如果你只是通过滚动选项获得警报

,那么其他的东西就错了。


-

Randy


Randy,


感谢您的回复,但我认为我的
$ b存在误解$ b问题。


首先,我没有选择一个optgroup。我正在选择

列表中的下一个选项(恰好在下一个选择组中)。


其次,重要的是你使用鼠标滚轮选择

实现问题的选项。不要下拉选择框。

实际上,我可以看出,当选择

框被下拉时鼠标滚轮不起作用;它仅在选择框聚焦时有效但

没有下拉。


我提供的代码最初侧重于选择框;只需使用你的

鼠标滚轮,就会选择新的选项。


如果鼠标滚轮在A1和A2之间滚动,则onchange事件是

正确调用;但是,如果你在A3和B1之间鼠标滚轮scrool,

onchange事件没有被调用。我相信它应该被称为。


谢谢,

Ryan McGeary


***通过Developersdex发送< a rel =nofollowhref =http://www.developersdex.comtarget =_ blank> http://www.developersdex.com ***

Don 只是参加USENET ......获得奖励!


" Ryan McGeary" < RY ********* @ hotmail.com>在消息中写道

新闻:d5 ************************* @ posting.google.co m ... < blockquote class =post_quotes>在< select>中下拉时,当使用鼠标滚轮滚动下拉菜单并在新的< optgroup>上穿过
时,不会调用onchange事件。

使用下面的例子,注意当鼠标滚轮在A3和B1之间滚动时如何调用onchange事件
,但在A1和A2之间滚动时它是否正常工作

例如
------------------------------------------
< html>
< body onload =" document.forms [''myForm'']。elements [''mySelect'']。focus()">
< form name =" myForm" id =" myForm">
< select onchange =" alert(''onchange event'');" name =" mySelect"
id =" mySelect">
< optgroup label =" A组">
< option value =" A1"> A1< ; / option>
< option value =" A2"> A2< / option>
< option value =" A3"> A3< / option>
< / optgroup>
< optgroup label =" B组"
< option value =" B1"> B1< / option>
< option value =" B2"> B2< / option>
< option value =" B3"> B3< / option>
< / optgroup>
< optgroup label =" Group C"
< option value =" C1"> C1< / option>
< option value =" C2"> C2< / option>
<选项值=" C3"> C3< / option>
< / optgroup>
< / select>
< / form>

< ; / body>
< / html>
---------------- --------------------------

谢谢,
Ryan McGeary



我从未听说过optgroup之前我去看了。


我在WAP(无线应用协议)下发现它。

http://www.w3schools.com/wap/tag_optgroup.asp


并不表示label =支持。


In a <select> drop-down, the onchange event isn''t called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.

Using the example below, notice how the onchange event isn''t called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.

E.g.
------------------------------------------
<html>
<body onload="document.forms[''myForm''].elements[''mySelect''].focus()">

<form name="myForm" id="myForm">
<select onchange="alert(''onchange event'');" name="mySelect"
id="mySelect">
<optgroup label="Group A">
<option value="A1">A1</option>
<option value="A2">A2</option>
<option value="A3">A3</option>
</optgroup>
<optgroup label="Group B">
<option value="B1">B1</option>
<option value="B2">B2</option>
<option value="B3">B3</option>
</optgroup>
<optgroup label="Group C">
<option value="C1">C1</option>
<option value="C2">C2</option>
<option value="C3">C3</option>
</optgroup>
</select>
</form>

</body>
</html>
------------------------------------------

Thanks,
Ryan McGeary

解决方案

In article <d5*************************@posting.google.com> ,
ry*********@hotmail.com (Ryan McGeary) writes:

In a <select> drop-down, the onchange event isn''t called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.
Nor should it be. The onchange event shouldnt fire until a different option
(optgroups are not options) has been chosen.
Using the example below, notice how the onchange event isn''t called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.



The only way I get an alert out of that code is after I choose a different
option and leave the select list. As it should be. If you are getting the alert
simply by scrolling through the options, then something else is wrong.

--
Randy


Randy,

Thanks for the reply, but I think there''s a misunderstanding with my
issue.

First, I''m not selecting an optgroup. I''m selecting the next option in
the list (which happens to be in the next optgroup).

Second, it''s important that you use the "mouse wheel" to select between
the options to realize the issue. Do not "drop-down" the select box.
In fact, what I can tell, the mouse wheel doesn''t work when the select
box is "dropped-down"; it only works when the select box is focused but
not "dropped-down."

The code I provided initially focuses on the select box; simply use your
mouse wheel and new options will be selected.

If you mouse wheel scroll between A1 and A2, the onchange event is
correctly called; however, if you mouse wheel scrool between A3 and B1,
the onchange event isn''t called. I believe it should be called.

Thanks,
Ryan McGeary

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


"Ryan McGeary" <ry*********@hotmail.com> wrote in message
news:d5*************************@posting.google.co m...

In a <select> drop-down, the onchange event isn''t called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.

Using the example below, notice how the onchange event isn''t called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.

E.g.
------------------------------------------
<html>
<body onload="document.forms[''myForm''].elements[''mySelect''].focus()">

<form name="myForm" id="myForm">
<select onchange="alert(''onchange event'');" name="mySelect"
id="mySelect">
<optgroup label="Group A">
<option value="A1">A1</option>
<option value="A2">A2</option>
<option value="A3">A3</option>
</optgroup>
<optgroup label="Group B">
<option value="B1">B1</option>
<option value="B2">B2</option>
<option value="B3">B3</option>
</optgroup>
<optgroup label="Group C">
<option value="C1">C1</option>
<option value="C2">C2</option>
<option value="C3">C3</option>
</optgroup>
</select>
</form>

</body>
</html>
------------------------------------------

Thanks,
Ryan McGeary


I''d never heard of "optgroup" before so I went looking.

I found it under WAP (Wireless Application Protocol ).

http://www.w3schools.com/wap/tag_optgroup.asp

does not indicate that "label=" is supported.


这篇关于IE Bug:使用&lt; optgroup&gt;时未调用onchange事件在选择下拉列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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