Javascript 如何防止电话号码被转换成Skype链接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3032427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to prevent phone numbers to be converted into Skype links?
提问by Ain Tohvri
On those Windows machines with Skypeinstalled, it tends to convert all phone-formatted numbers to Skype links so you can click it in order to make a call on Skype.
在那些安装了Skype 的Windows 机器上,它倾向于将所有电话格式的号码转换为 Skype 链接,以便您可以单击它以在 Skype 上拨打电话。
The question is how do you prevent that to happen for a certain number on page?
问题是您如何防止页面上的某个数字发生这种情况?
回答by John Saunders
Try not outputting the numbers as a single piece of text. Instead of
尽量不要将数字作为单个文本输出。代替
<span>888-555-1212</span>
try
尝试
<span>888-</span><span>555-1212</span>
and it will disable skype
它会禁用Skype
回答by Groo
Update
更新
This answer is no longer accurate - see Daniel Byrne's answerfor more information.
此答案不再准确 -有关更多信息,请参阅Daniel Byrne 的答案。
Using CSS only, it can be removed by overriding the styles used by Skype. Try adding these two lines to your stylesheet:
仅使用 CSS,可以通过覆盖 Skype 使用的样式来删除它。尝试将这两行添加到您的样式表中:
span.skype_pnh_container {display:none !important;}
span.skype_pnh_print_container {display:inline !important;}
回答by Daniel Byrne
Skype has taken to adding a randomly generated string of numbers to the end of their span tag, so the above response from Groo is not entirely accurate anymore. To correctly select all Skype tags on a page, use CSS3 wildcard selectors like such :
Skype 已经开始在其 span 标签的末尾添加一个随机生成的数字字符串,因此来自 Groo 的上述响应不再完全准确。要正确选择页面上的所有 Skype 标签,请使用 CSS3 通配符选择器,例如:
span[class^='skype_pnh_container'] {display:none !important;}
span[class^='skype_pnh_print_container'] {display:inline !important;}
the ^=operator causes an attribute selector to mach elements that have an class containing a value that STARTS WITH 'skype_pnh_container' and 'skype_pnh_print_container'
该^=运算符使属性选择器对具有包含以 'skype_pnh_container' 和 'skype_pnh_print_container' 开头的值的类的元素进行 mach
回答by richddr
The official solution is to add the following meta tag to the head section of your webpage. This will prevent skype from doing any reformatting on phone numbers.
官方的解决方案是将以下元标记添加到您网页的 head 部分。这将阻止 Skype 对电话号码进行任何重新格式化。
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
This is a vendor-specific tag. See Skype Toolbar meta tag
这是供应商特定的标签。请参阅Skype 工具栏元标记
回答by dobs
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
回答by xon1c
EDIT: Sorry, I just discovered that IE9 has issues with this solution as it does not support soft hyphens.
编辑:对不起,我刚刚发现 IE9 有这个解决方案的问题,因为它不支持软连字符。
There is an alternative solution to this problem:
这个问题有一个替代解决方案:
You can use a soft-hyphen character (­) inside the phone number to address the issue. For example, given the number
您可以­在电话号码中使用软连字符 ( ) 来解决此问题。例如,给定数字
<span>0664 111 222 3</span>
change to
改成
<span>0664­ 111 222 3</span>
and be happy :)
而且要快乐 :)
回答by Yoni
I just found that if you use the new HTML5 tel protocol it blocks the Skype junk from appearing:
我刚刚发现,如果您使用新的 HTML5 电话协议,它会阻止 Skype 垃圾出现:
<a href="tel:+18001234567">1 800 123 4567</a>
回答by lukart
I saw over the interweb a lot of possible solutions javascript solutions, meta tags, css and maybe I found an hack actually working for my websites, I tested on some computers and it work and I think it will work until skype don't change something in their code.
我在互联网上看到了很多可能的解决方案 javascript 解决方案、元标记、css,也许我发现了一个实际上适用于我的网站的 hack,我在一些计算机上进行了测试,它可以工作,我认为它会工作,直到 Skype 不改变某些东西在他们的代码中。
I was looking what is the skype exactly doing on our pages, and it creates some span around the phone numbers, as you already said, but it even add an tag at the end of the document, just after the body closed tag.
我正在查看 Skype 在我们的页面上到底在做什么,它在电话号码周围创建了一些跨度,正如您已经说过的,但它甚至在文档末尾添加了一个标签,就在正文关闭标签之后。
And here I saw the trick! Just before that object there is a configuration tag:
在这里我看到了诀窍!在该对象之前有一个配置标签:
<span id="skype_highlighting_settings" display="none" autoextractnumbers="1"></span>
This is added dynamically by the plugin! but here the solution become obvious, to finalle stop skype messing with your design and avoid changing phone number the solution is to insert very early in the document the following tag:
这是由插件动态添加的!但在这里解决方案变得显而易见,为了最终停止Skype弄乱您的设计并避免更改电话号码,解决方案是在文档的早期插入以下标签:
<span id="skype_highlighting_settings" display="none" autoextractnumbers="0"></span>
notice the autoextractnumbers="0", here is the trick. The document will not validate anyway with that tag because there is no attribute "autoextractnumbers" but i noticed that it works even if commented:
注意 autoextractnumbers="0",这是诀窍。该文档无论如何都不会使用该标签进行验证,因为没有属性“autoextractnumbers”,但我注意到即使注释它也能工作:
<!-- <span id="skype_highlighting_settings" display="none" autoextractnumbers="0"></span> -->
And that's it! Enjoy your webpages free from messy plugins! And your web page will still validate correctly. Hope it works for you too! I have tested on a couple of computer 3 different browsers and 2 different skype versions, for now it works for me, let me know if it works for you too and if it works share it :)
就是这样!享受没有杂乱插件的网页!您的网页仍将正确验证。希望它也对你有用!我已经在几台计算机上测试了 3 个不同的浏览器和 2 个不同的 Skype 版本,现在它对我有用,让我知道它是否也适用于你,如果它有效分享它:)
回答by Juan
I added a space in the first term of the number.
我在数字的第一项中添加了一个空格。
Instead of (888) 222-3333 I entered ( 888 ) 222-3333
我输入了 (888) 222-3333 而不是 (888) 222-3333
Granted: may look weird, but it works and it is simple.
当然:可能看起来很奇怪,但它有效而且很简单。
回答by Stu
I added a hyphen in a span before the number and then set display:none on the span style, which worked.
我在数字之前的跨度中添加了一个连字符,然后在跨度样式上设置 display:none ,这有效。
<span class="anti-skype-hyphen">-<span>01273 200 ***

