简体   繁体   中英

Don't want telephone link to call out in brwsers just phones

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM