简体   繁体   English

如何判断移动Safari中正在点击哪个“按钮”?

[英]How can I tell which “button” is being tapped in mobile Safari?

I have an html "button" which is really just this: 我有一个html“按钮”,实际上就是这样:

<div onClick="window.location.href=somePage.htm">
    <img src="img.png"/>
</div>

Works fine in desktop Safari. 在桌面Safari中工作正常。 And it works in mobile Safari... however when I tap the "button" in mobile safari I don't see the little gray outline box indicating exactly what I'm tapping. 它可以在移动Safari中使用...但是,当我在移动Safari中点击“按钮”时,我看不到灰色的轮廓框,确切地表明了我正在点击的内容。 How can I get this little gray outline box to show up? 如何显示这个灰色的小轮廓框? I find this feature of mobile Safari to be very useful and I'd like to provide it for the user. 我发现移动Safari的此功能非常有用,我想为用户提供此功能。

Cheers! 干杯!

您应该使用链接。

I think that mobile Safari applies this to clickable elements only. 我认为移动Safari仅将此应用于可点击元素。 Have a look at this documentation . 看看这个文档 I would suggest that you simply use a <a> -element for this purpose: 我建议您为此使用一个<a> -element:

<a onclick="window.location.href = somePage.htm; return false;">
    <img src="img.png" />
</a>

This should work exactly like your <div> with a little styling. 这应该与您的<div>完全一样,但带有一些样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM