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.
Asked
Active
Viewed 531 times
2
-
Can you elaborate where and how this is actually occurring; what do you mean by 'browsers' and 'devices'? – WDUK Nov 08 '12 at 21:53
-
Welcome to SO. It's not too much clear what are you asking. Can you please reformulate your question? – Tony Rad Nov 08 '12 at 21:53
-
Check the Agent tag and don't make it a link if its a desktop browser? – Andrew T Finnell Nov 08 '12 at 21:53
1 Answers
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.