17

I'm looking to use the tel: uri scheme (rfc3966) to make phone numbers linkable on mobile devices in a web application, but I'd prefer to not link them on devices that can't handle the tel: scheme - desktops, or mobile devices without phone functionality (i.e. iPads!)

Is there some way to detect this? I'd prefer to avoid user agent sniffing, if possible.

The iPhone seems to have a canOpenURL function that apps can use to test this, but I'd like to get the same behaviour from Javascript.

Korny
  • 1,988
  • 1
  • 18
  • 16

3 Answers3

4

There's no standard way of detecting browser support for the tel URI scheme.

You can however user-agent sniffing library, such as the excellent WURFL library which can detect this feature.

James Goodwin
  • 7,360
  • 5
  • 29
  • 41
  • Would you happen to know whether this situation has changed much over the past year? (I suspect not.) Thanks for the answer. – Pointy Feb 12 '12 at 20:38
  • Not as far as I know, would be nice to see some kind of JavaScript support to detect this. Best bet would be to just place the telephone number on the page and hope that the phone interprets it as a phone number and converts it into it's version of the `tel:` link. – James Goodwin Feb 17 '12 at 17:25
  • Yes, though the ugly part isn't only whether it does something useful on the phone, but also whether desktop browsers will do something clumsy. Desktop Firefox gives the user a nice dialog explaining that the URL scheme is not recognized, which is of course utterly wasted on normal people just looking at a page. Well again, thanks! – Pointy Feb 17 '12 at 17:36
  • User-Agent sniffing is not the answer, the user agent string cannot determine if a device has the capability, there is simply not enough information provided. Is Skype Installed, is this android device a tablet, or running on a pc? – Chris Seufert Jul 18 '17 at 04:12
1

The iPhone will automatically pick up whether general text is in phone number format and turn it into a clickable link. No effort required on your side.

ie If you have text "+61 (0)7 3000 0000" on your site the iPhone will know it's a number and make it a link.

Jon
  • 41
  • 5
  • 1
    Other mobile devs have told me that it's best to turn this feature off, as it tends to aggressively turn other stuff into clickable links as well - such as postcodes, post office boxes, and other long strings of numbers. The advice might be out of date - anyone know if this is still a problem? – Korny Feb 27 '11 at 03:42
  • 8
    @Korny It's a problem/feature depending on how useful you think it is. It can be disbaled by using `` – James Goodwin Feb 27 '11 at 14:50
0

The MobileESP project has APIs for several server-side languages, as well as a client-side JavaScript API.

Oh! and it's free and open-source (Apache license I believe)

Maurice Perry
  • 32,610
  • 9
  • 70
  • 97