驯服自动电话号码的事情在windows 10的边缘浏览器 [英] Taming the automatic telephone number thing in the windows 10 edge browser

查看:135
本文介绍了驯服自动电话号码的事情在windows 10的边缘浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使系统上没有安装手机应用程式,Windows 10的边缘浏览器似乎也会侦测电话号码。



它会以蓝色标示电话号码,它只是在纯文本(某些背景上丑陋),而且它检测eg



因此,我们如何将其控制为网站管理员:



    $


  • 如何做到我们关闭检测




最好是只有针对浏览器的东西, -




  • 建议的方法来关闭检测关闭基于在IE11中的Windows Phone手机的方式不工作在我的所有测试。元标记失败,非标准html属性似乎可以正常工作。


  • 我已经看过边缘的检查项目,对于那些检测到的项目的计算的CSS是如果没有检测到(即计算的CSS是正常的颜色和没有下划线,那将是期望看到的),暗示控制它的呈现的机会很少。




编辑:



测试用例1:元标记b
$ b

 <!DOCTYPE html>< html xmlns =http://www.w3.org/1999/xhtmlxml:lang =enlang =en> < head> < meta charset =UTF-8/> <! -  test  - > < meta name =format-detectioncontent =telephone = no/> < / head> < body> < p>文字增值税BE 0123.456.789 text< / p> < p>文字+32 11 222 333文字< / p> < / body>< / html>  



测试用例2 :非标准html属性(作品)



 <!DOCTYPE html>< html xmlns =http://www.w3。 org / 1999 / xhtmlxml:lang =enlang =en> < head> < meta charset =UTF-8/> < / head> < body> < p x-ms-format-detection =none>文字增值税BE 0123.456.789 text< / p> < p>文字+32 11 222 333文字< / p> < / body>< / html>  

解决方案

显然,在Internet Explorer 11中引入了电话号码检测功能,但在桌面上则无此功能。



这里有一些控制方法, :电话号码格式识别




  • 要禁用元素(及其子元素)的行为,请设置 x-ms-format-detection 属性为none。

  • 要禁用网页的行为,请使用元素元素:



< meta name =format-detectioncontent =telephone = no/>




  • 要启用元素(及其子元素)的行为,请将 x-ms-format-detection 属性设置为phone或all。


  • 要使用JavaScript选择性地控制行为,请使用 setAttribute 更改associate元素或其父元素的 x-ms-format-detection 属性的值。 (请注意,这需要在元素或父元素在DOM中呈现之前完成;不支持动态更改。)




如果我理解文章正确,如果手机检测在浏览器级别被禁用, x-ms格式检测属性(或元标记)被忽略。


Windows 10's edge browser seems to detect phone numbers even if there's no phone app installed on the system.

It formats the phone number in blue with an underline even if it's just in the plain text somewhere (ugly on some backgrounds), moreover it detects e.g. VAT numbers as if they were phone numbers.

So how do we control it as webmasters to:

  • how it renders the detected stuff (I suppose MSFT invented their very own CSS selector for this stuff?)

  • how do we turn the detection off

Preferably with something just targeting that browser and not risk messing up things for others or adding non-standard things to otherwise valid code.

EDIT:

  • The suggested way to turn detection off based on the way it is done in IE11 for windows phones does not work in all of my tests. The meta tag fails and the non-standard html attribute does seem to work.

  • I've looked at the inspect thing in edge and it seems to me the computed CSS for those detected items is what one would expect to see there if it were not detected (i.e. the computed CSS is the normal color and no underline), suggesting little chance of controlling how it's rendered.

EDIT:

test case 1: meta tag (fails)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta charset="UTF-8" />
    <!-- test -->
    <meta name="format-detection" content="telephone=no" />
  </head>
  <body>
    <p>text VAT BE 0123.456.789 text </p>
    <p>text +32 11 222 333 text</p>
  </body>
</html>

Test case 2: non-standard html attribute (works)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <p x-ms-format-detection="none">text VAT BE 0123.456.789 text </p>
    <p>text +32 11 222 333 text</p>
  </body>
</html>

解决方案

Apparently phone number detection was introduced in Internet Explorer 11, but not on desktops.

Here are ways to control it, taken from this MS article: Phone number format recognition

  • To disable the behavior for an element (and its child elements), set the x-ms-format-detection attribute to "none".
  • To disable the behavior for a webpage, use the meta element:

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

  • To enable the behavior for an element (and its child elements), set the x-ms-format-detection attribute to "phone" or "all".

  • To selectively control the behavior using JavaScript, use setAttribute to change the value of the x-ms-format-detection attribute of the associate element or its parent. (Note that this needs to be done before the element or the parent is rendered in the DOM; dynamic changes are not supported.)

If I understand the article correctly, if phone detection is disabled at the browser level, the x-ms-format-detection attribute (or the meta tag) will be ignored.

这篇关于驯服自动电话号码的事情在windows 10的边缘浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆