Search code examples
htmlbuttonmobile-safari

How can I tell which "button" is being tapped in mobile Safari?


I have an html "button" which is really just this:

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

Works fine in desktop 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. 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.

Cheers!


Solution

  • I think that mobile Safari applies this to clickable elements only. Have a look at this documentation. I would suggest that you simply use a <a>-element for this purpose:

    <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.