Skip to content Skip to sidebar Skip to footer

A Href Tel And Standard Browsers

Solution 1:

Detect with PHP if its a mobile agent: http://www.000webhost.com/forum/scripts-code-snippets/27404-php-extremely-simple-way-check-if-mobile-browser.html

<?phpif(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'android')) {
           echo'<a href="tel:123456">';
        }else{
           echo'You are not in a mobile';
        }
   ?>

Solution 2:

Since you're using PHP I can recommend the php-mobile-detect class. You can cater to individual devices/OS'es/browsers, or simply use isMobile() or isTablet() as a catch-all.

I usually do something like this:

include'./includes/Mobile_Detect.php';
$detect = new Mobile_Detect;

if ( $detect->isMobile() or$detect->isTablet() ){
    $phone='<a href="tel:+12345678910">1-234-567-8910</a>';
} else {
    $phone='1-234-567-8910';
}

Then I just <?php echo $phone;?> wherever I need it and it works a treat! And by using PHP instead of javascript it means the detection is done server-side, so the end user has less to download (like jQuery and extra scripts).

The library of devices gets updated fairly often, so it's worth checking the GitHub page every so often.

Solution 3:

You want to detect, whether a user has a mobile browser or not? This might help:

http://jquerybyexample.blogspot.com/2012/03/detect-mobile-browsers-using-jquery.html

Solution 4:

Try this below one :

Syntex : callto

<ahref="callto://9566603286">9566603286</a><?phpif(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'android')) {
       echo'<a href="callto://9566603286">9566603286</a>';
    }else{
       echo'You are not in a mobile';
    }
 ?>

Post a Comment for "A Href Tel And Standard Browsers"