display image ONLY if ipad/ipod/iphone is detected
Hi
I have images in my site that display text over them on mouse over.
silly me, well obviously the ipad needs a click!
SO my only thoughts are to make a small info button appear in each of the images,
so they know to click there.
I want them only to appear only on ipad, iphone, ipod, or touch devices in general.
you can do that in a more simple way.
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad'))
{?>
<div class="infoclick"></div>
<?php }?>
also for you may have to add few more user agents to target touch screen devices, as there are millions Android as well
hey thanks very much. that works well, but still appears in non touch devices?
dam, maybe this hover idea was not a good one at all after all, if I have to have many more user agents. sigh*
Here is a very useful JS code to detect devices or specific browsers in general:
Code:
// Javascript iPhone iPad iPod detection example
var uAgent=navigator.userAgent.toLowerCase();
if(uAgent.indexOf("ip")>-1) {
// do some action, for example:
window.location.replace("www.mysite.com/mobile.html");
}
Note: that above code works with iPad/iPhone/iPod because it detects an "ip" text-value in the navigator-name detection, but you can change the value in order to detect whatever you want.
In the example, if an Apple mobile device is detected, the code redirects to a specific page you may build for mobile devices... but you can do anything you want.
Hope that will help someway ;-)
Last edited by MrSnowDrop; 09-19-2012 at 05:34 AM.
Bookmarks