2

I'm using because i have other numbers on the page that are not phone numbers and don't want them detected. I wrap the number in a link but I don't want it to be clickable in browsers, only on devices.

richard
  • 65
  • 1
  • 1
  • 7

1 Answers1

3

This is actually quite simple, Apple's documentation describes it quite thoroughly -

// Disable automatic telephone number detection
<meta name = "format-detection" content = "telephone=no">

// Explicitly mark a number as a telephone number
<p>A phone number: <a href="tel:1-408-555-5555">1-408-555-5555</a></p>

To prevent the link doing anything when it's clicked on a desktop browser, you can do some browser sniffing...

$('a.someClass').click(function(e) {
    if (!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
        e.preventDefault();
    }
});

However, why would you want to cripple this functionality in desktop browsers in an age where the use of software such as Skype for VOIP is commonplace? For an excellent discussion of why browser sniffing is a bad idea, see this question.

Community
  • 1
  • 1
Kelvin
  • 4,909
  • 21
  • 35