[英]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 -这实际上很简单, Apple 的文档对其进行了非常彻底的描述——
// 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?但是,在使用 Skype 等 VOIP 等软件司空见惯的时代,您为什么要在桌面浏览器中削弱此功能? For an excellent discussion of why browser sniffing is a bad idea , see this question .
有关为什么浏览器嗅探是个坏主意的精彩讨论,请参阅此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.