I am using the onmouseover to start a function for mobile devices for a website. The function is to make a dropdown menu dropdown. The function is called and works on iphones, but not on androids. Any ideas of how to fix it?
Asked
Active
Viewed 1,418 times
2
-
4Why are you trying to use `onmouseover` on devices that simply do not support a mouse? Seems like time to consider if you're trying to put a square peg in a round hole – Tibrogargan Sep 21 '18 at 03:08
-
[Of (potential) interest](https://stackoverflow.com/questions/37113082/detecting-hover-or-mouseover-on-smartphone-browser) – Sep 21 '18 at 03:16
2 Answers
0
There is no mouse to move in a touch environment like android. The common approach is to detect a long-press for some special actions.
There is also a onpointermove
event associated to a more generic pointer as in mobile devices, but there is no full support for it. However, some devices could not report any mouse/pointer movement event, because there is no movable pointer.
See also: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onpointermove (event)
https://www.w3.org/TR/pointerevents/#widl-GlobalEventHandlers-onpointermove (W3C Specification)

F.Igor
- 4,119
- 1
- 18
- 26
0
You can register a touch event on the same element:
- ontouchcancel: The event occurs when the touch is interrupted
- ontouchend: The event occurs when a finger is removed from a touch screen
- ontouchmove: The event occurs when a finger is dragged across the screen
- ontouchstart: The event occurs when a finger is placed on a touch screen
In this case "ontouchstart" will be the adecuated, or maybe the "onclick" event will be good too.

Shidersz
- 16,846
- 2
- 23
- 48