什么DOM事件可用于WebKit的Andr​​oid上?事件、可用于、DOM、oid

2023-09-12 21:58:31 作者:爱你至死不渝

我要建一个移动web应用程序针对Android用户。我需要知道什么DOM事件提供给我。我已经能够做下面的工作,但不是非常可靠:

I'm building a mobile web app targeting Android users. I need to know what DOM events are available to me. I have been able to make the following work, but not terribly reliably:

点击 在鼠标悬停 鼠标按下 鼠标松开 更改

我一直没能得到以下工作:

I have not been able to get the following to work:

键preSS 的keydown KEYUP

有谁知道是什么样的支持和在什么情况下都能充分列表(例如,是的onchange只适用于表单输入?)?我无法找到该上的Google的一个参考。

Does anyone know the full list of what is supported and in what contexts (e.g., is onchange only available to form inputs?)? I can't find a reference for this on The Googles.

谢谢!

更新:我问the同样的问题在Android开发者列表。我会做一些更多的测试,并都将在这里和那里后我的结果。

Update: I asked the same question on the Android developers list. I will be doing some more testing and will post my results both here and there.

推荐答案

OK,这是有趣的。我用例是我有一系列的WebKit的视图的画面上的链接( A 标签)。要测试什么事件地区提供,使用jQuery 1.3.1,我安装在此页面(甚至是那些没有意义)的链接,然后使用向上,向下,并输入Android模拟器的控制,并指出该事件中的情况下解雇了。

OK, this is interesting. My use case is that I have a series of links (A tags) on a screen in a WebKit view. To test what events area available, using jQuery 1.3.1, I attached every event listed on this page (even ones that don't make sense) to the links then used the up, down, and enter controls on the Android emulator and noted which events fired in which circumstances.

下面是code口用于连接的事件,其结果跟随。请注意,我使用的是活的事件,因为我的应用程序绑定, A 标签动态插入。

Here is the code I used to attach the events, with results to follow. Note, I'm using "live" event binding because for my application, the A tags are inserted dynamically.

$.each([
    'blur',
    'change',
    'click',
    'contextmenu',
    'copy',
    'cut',
    'dblclick',
    'error',
    'focus',
    'keydown',
    'keypress',
    'keyup',
    'mousedown',
    'mousemove',
    'mouseout',
    'mouseover',
    'mouseup',
    'mousewheel',
    'paste',
    'reset',
    'resize',
    'scroll',
    'select',
    'submit',

    // W3C events
    'DOMActivate',
    'DOMAttrModified',
    'DOMCharacterDataModified',
    'DOMFocusIn',
    'DOMFocusOut',
    'DOMMouseScroll',
    'DOMNodeInserted',
    'DOMNodeRemoved',
    'DOMSubtreeModified',
    'textInput',

    // Microsoft events
    'activate',
    'beforecopy',
    'beforecut',
    'beforepaste',
    'deactivate',
    'focusin',
    'focusout',
    'hashchange',
    'mouseenter',
    'mouseleave'
], function () {
    $('a').live(this, function (evt) {
        alert(evt.type);
    });
});

下面是它的震撼了:

在第一页加载什么也没有突出显示(周围的任何项目没有丑陋的橙色选择框),用上下键选择第一项,以下事件发射(按顺序):鼠标悬停的mouseenter 鼠标移动 DOMFocusIn

通过选择一个项目,使用向下键移动到下一个项目,以下事件发射(按顺序):的mouseout 鼠标悬停鼠标移动 DOMFocusOut DOMFocusIn

With an item selected, moving to the next item using the down button, the following events fired (in order): mouseout, mouseover, mousemove, DOMFocusOut, DOMFocusIn

随着项目选中,点击确认按钮,出现如下事件发射(按顺序):鼠标移动鼠标按下 DOMFocusOut 鼠标松开点击等待DOMActivate

With an item selected, clicking the "enter" button, the following events fired (in order): mousemove, mousedown, DOMFocusOut, mouseup, click, DOMActivate

这令我一堆随机的垃圾。而且,那是谁厚颜无耻的IE浏览器,唯一的事件(的mouseenter )做一个客串,然后服用一天的休息了吗?哦,好吧,至少现在我知道看什么事件。

This strikes me as a bunch of random garbage. And, who's that cheeky IE-only event (mouseenter) making a cameo, then taking the rest of the day off? Oh well, at least now I know what events to watch for.

这将是巨大的,如果别人想利用我的测试code,并通过做更彻底的运行,可能使用表单元素,图像等。

It would be great if others want to take my test code and do a more thorough run through, perhaps using form elements, images, etc.