如何在Android浏览器中检测鼠标点击并按住?
我正在编写一个旨在在 Android 手机以及其他移动设备上查看的网页。我将使用网页而不是应用程序,因为它更独立于平台。
我想在用户单击并按住网页上的按钮时连续执行操作。在移动设备上,当他们将手指放在网页上的按钮上时,操作将连续运行。
我尝试在输入按钮的 onmousedown 事件上使用 javascript 函数 setInterval() ,在 onmouseup 事件上使用clearInterval() 。从 PC 上的任何浏览器访问设备时,这都非常有效。不幸的是,它不适用于我的 Android 手机。按下并按住时按钮外观似乎确实会更改为保持状态,但 onmousedown 事件不会被调用。
有没有人找到一种与 Android 设备兼容的按住按钮操作的好方法?
I am writing a webpage that is intended to be viewed on Android phones and hopefully other mobile devices. I am going with a webpage as opposed to an App because it is more platform independent.
I would like to perform an operation continuously while the uses is clicking and holding a button on the webpage. On mobile device the operation would run continuously when they hold their finger on the button on the webpage.
I have tried using the javascript function setInterval() on the onmousedown event of my input button and clearInterval() on the onmouseup event. This works perfectly when accessing the device from any browser on a PC. Unfortunately, it doesn't work on my Android phone. The button appearance does seem to change to the held state when pressed and held but the onmousedown event doesn't get called.
Has anyone found a good way to do press-and-hold button actions that is compatible with Android devices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查此处:
Android 上的 WebKit 可以使用哪些 DOM 事件?< /a>
和这里:
Quirksmode.org/mobile
似乎您需要使用一些 DOM或触摸处理程序(最后一个在使用轨迹球时可能会出现问题)
Check here:
What DOM events are available to WebKit on Android?
and here:
Quirksmode.org/mobile
Seems that you need to use some of the DOM or touch handlers (last one may have problems when using trackbal)