Browser detection script.
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
Im using your php browser detect script to determine if html5 canvas is supported. If it is i serve a html5 canvas map, if not i serve a flash map.
However due to IOS lack of decent support for canvas i have had to produce a slightly different canvas map for ios users (safari on ipad or iphone). How can i detect if they are using safari on ipad or iphone is this possible?
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4129
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
the browser detection script offers mobile, tablet, and device type detections, which, if you couple them with straight browser detection, will give you exactly what you need.

See the script top comments for full list of features and outputs.
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
:: Code ::

require('browser_detect_script.php');
$browser_array = browser_detection( 'full_assoc');
   
if($browser_array["html_type"]>1)
{
        //check if ios and safari
        $ios = false;
        $mobile_data = $browser_array["mobile_data"];
        if(is_array($mobile_data))
        {
            // first check if its a ipad or iphone.
            if(in_array($mobile_data[0], array("ipad", "iphone")))
            {
                // check if safari ???
                $ios == true;
            }
       
        }
       
       
        if($ios)
        {
            // serve safari ios canvas map
        }
        else
        {
            // serve standard canvas map
           
        }
}
else
{
        // serve flash map
}



I just want to know how to check if its safari i think. The problem is the mouse events are different. On all browsers on my test machines the javascript detects mousedown correctly but on safari ios for some reason when you click it thinks it is a mouseover event. Not sure if what other browsers on ios do. I know my android gets the mousedown event correct. Gahhhh need more testing devices :)
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
*** UPDATE ****

I just figured out that it pointless trying to get mouse events working for tablets mobile devices. These devices have touch events. So i just mad a full mobile / tablet version of the map that works on touch events and a desktop version with mouse events.

Now i can just do a simple HTML5 and Mobile check and voila

:: Code ::

    require('browser_detect_script.php');
    $browser_array = browser_detection( 'full_assoc');
    if($browser_array["html_type"]>1)
    {
        //serve canvas map
        $mobile_data = $browser_array["mobile_data"];
        if(is_array($mobile_data))
        {
            // serve special mobile map
           
        }
        else
        {
            // serve standard canvas map
           
        }
    }
    else
    {
        // serve flash map
       
    }



This seems to work so i don't need to detect ios after all. Just that its a mobile / tablet.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4129
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
ah, that's good.
Back to top
Zoidberg
Status: New User - Welcome
Joined: 10 Nov 2016
Posts: 1
Reply Quote
Sweet, thanks Tim. I tried it and it works great.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours