10

This might seem like a really dumb question, but I am writing an application and I have come across where my mouse-over, mouse-click and mouse-hover need different events bound to them. Now on Internet Explorer, Firefox, and Safari. It all works as expected.

However, on my iPhone the actions will not trigger. Now my question is are their any specific ways I can have the Mouse-Over essentially be fired when I hold my finger down and trigger an event?

An example where this doesn't work is right on this website when you hover over a comment it is supposed to display the +1 or flag icon.

I am using jQuery.

4

7 回答 7

29

答案在 Remus 发布的文档中。如果添加 onclick = "void(0)" 声明,您将指示 Mobile Safari 该元素是可点击的,并且您将获得对该元素的 mouseover 事件的访问权限。

更多信息在这里

于 2010-07-09T21:09:41.640 回答
15

I think you need to reconsider your design for the iPhone (and any mobile for that matter). iPhone web interfaces shouldn't depend on mouse-overs and hovers, as they just complicate the interface significantly.

I strongly recommend that you design a new interface that is optimized for mobile viewing, that don't require clicking on small tiny arrows just to show more options.

于 2009-11-30T23:55:44.773 回答
5

Mobile Safari has no mouse and hover events (at least not in the usual accepted sense), they are explicitly called out in Creating Compatible Web Content Unsupported iPhone OS Technologies:

Mouse-over events The user cannot “mouse-over” a nonclickable element on iPhone OS. The element must be clickable for a mouseover event to occur as described in “<a href="https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW7" rel="nofollow noreferrer">One-Finger Events.”</p>

Hover styles Since a mouseover event is sent only before a mousedown event, hover styles are displayed only if the user touches and holds a clickable element with a hover style. Read “<a href="https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW1" rel="nofollow noreferrer">Handling Events” for all the events generated by gestures on iPhone OS.

于 2009-11-30T23:58:30.510 回答
2

是的......我认为提出问题的人实际上并不希望设备“感知”悬停或鼠标悬停。实际上,您必须非常自大才能假设某人确实是这个意思。需要一些触发这些事件处理程序的方法。我绝对可以在项目上方出现的“提示”文本中看到它们的用途。

无论谁说不使用鼠标事件会带来更清洁、更简单的体验,都是把他们自己的观点看得太认真了。这些可以极大地增强网页/应用程序体验或使它们变得更糟。这是一个谨慎使用的问题。

任何人在这里提供的唯一有价值的答案是,谁说最好有一个针对移动设备优化的备用网站。或者可能使用基于浏览器类型生成页面的内容管理系统(类似于维基百科的工作方式)。

于 2010-05-05T03:55:37.503 回答
1

Congratulations on discovering the first thing about touch screen UI design. The bad news, is that what you want just is not going to happen.

The good news is that this will force you to make a much easier interface, for both iphone users and regular web users.

于 2009-11-30T23:58:48.900 回答
0

You simply cannot have a mouseover or hover functionality on touch screen devices, unless you can move a virtual pointer (though no touch UI offer that kind of functionality), but that would defeat the point of a touch screen UI.

Touch screen UI's are a paradigm shift and retro-fitting mouse-pointer UI interfaces back into touch UI design only limits and damages your solution.

于 2009-11-30T23:58:59.667 回答
-1

用 javascript 编写鼠标处理程序似乎相当简单,尽管我可以想象很容易让很多边缘情况出错。

好消息是,有人写了一个javascript鼠标处理程序/模拟器——作为一个书签。它被称为 iCursor(不要与同名的毫无意义的 mac 应用程序混淆)。

坏消息是,这家伙的网站 (icursor.mobi) 已经停播,我找不到副本,所以我无法告诉你它的效果如何。 这是一篇评论(因为我只能发布一个链接):

苹果应该为 iPhone/iPad 做的就是让单指平移移动虚拟鼠标指针,两指平移在视口内移动(就像现在的单指一样)。

两指平移很容易;我能想象苹果这样做的唯一原因是他们实际上想破坏世界上 50% 的网站。严重地。微软这些年来一直在做的破坏标准的邪恶操纵尝试就在那里。

您是一名网络开发人员。你最讨厌什么?IE浏览器。由于所有额外的头痛,它会导致你。好吧,Stevie 必须有他的“我也是”的时刻,而你要为此付出代价。

于 2010-11-16T17:10:57.760 回答