English 中文(简体)
试图理解点击 <select> 元素上的事件
原标题:trying to understand click events on <select> elements

当点击事件处理器注册在 select 元素上时, 我发现浏览器上的行为非常不一致。 我设置了一个 < a href=>。 我设置了一个 < a href=> http://jsfidle.net/philo/ LaWGS/ >jsfidle demo 。 下面我看到的是 :

  • Firefox 12 on OS X (10.7 Lion): Event fires when the element is clicked. The dropdown opens briefly, does not stay open. Keyboard actions don t generate click actions.
  • Firefox 12 on Linux (Ubuntu Lucid): same
  • Chome 19 on OS X: No mouse or keyboard interaction triggers the click event.
  • Chrome 19 on Linux: First mouse click expands options, subsequent click on either the still-present select, or the options, triggers click event.
  • Safari 5.1.6 on OS X: Similar to Chrome on Linux, first click expands options, subsequent click on options triggers click event (unlike Chrome, Safari hides the select element when showing options).
  • Android Browser (on Ice Cream Sandwich): Initial click triggers event. Options stay visible after the event, and can be clicked. Clicking the options doesn t trigger another event.
  • Chrome Beta for Android (Ice Cream Sandwich): Same as Android Browser.

如果有人能告诉我或者指给我标准,我会很高兴,但我想这并没有那么有用,因为我直接观察到没有人跟踪它。我怀疑这是一件不寻常的事情,试图这样做,也许更常见的是倾听改变事件。这是否属实?听点击选项的是什么?我无法做到这一点,但这可能是个愚蠢的错误。

(为了多给一点上下文, 我将替换一个基于 Google 关闭 s goog. ui. select 的选定元素, 因为该元素可以模仿一些桌面 < code> 选择 的图像, 特别是铬 s, 但无法在移动浏览器上完成扩展选项的全屏翻接。 应用程序先前监听了该组件 < code>goog. ui. component. EventType.ACtion 事件, 但它在任何地方都没有清晰的类比, 所以我只是想找到一个一致的替代选项 。)

问题回答

s 这里的 HTML 生活标准, 2013年7月12日最后一次更新( 2013年7月14日访问) 。 此链接将您直接引入 SELECT 元素。 在其它区域, 它表示任何 HTML 元素都应该能够处理一个点击事件, 并举例说明使用 javacript 添加听众。 当然, 问题其实是哪个浏览器可靠地支持指定的标准...

HTML标准





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签