让前端飞Web前端之路

Internet Explorer 11 automatical

2017-08-23  本文已影响34人  EdmundChen

Phone number format recognition

Internet Explorer 11 automatically turns phone numbers into clickable links. This feature works when you have an app that can handle phone numbers, such as Skype.
Here's the developer's perspective phone number detection, including the HTML elements that enable this feature by default and how to turn the feature off when necessary.
Understanding phone number detection
When Internet Explorer in the new Windows UI encounters a telephone number as part of content rendered using a supported HTML element, it turns the number into a clickable link (and does so without modifying the DOM). When the user clicks the link, the app registered to the "tel" URI protocol is invoked.

Note Phone number format recognition is not supported for Internet Explorer for the desktop, for applications hosting the WebBrowser control, or for IE11 for Windows 7.

Phone number detection comes into play for the following content patterns:

<element>425-882-8080</element>

425.<element>882</element>.8080

(425) 882-8080

For more examples and details, see How phone number detection works.Phone numbers are also recognized across entities that span inline elements. This means the display property must be set to "inline".
In the patterns shown earlier, "<element>" refers to one of the following HTML elements:

image.png

Certain exceptions apply, however. Phone number format recognition is disabled when the contentEditable attribute set to "true". It can be also disabled though group policy or user preferences.
Controlling phone number detection
There are a few different ways to control phone number format recognition:

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

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:
JavaScript

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

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.)

Remember, there is no guarantee that phone number detection will be enabled for IE11. Users can turn the feature off using preferences and administrators can disable the feature using group policies. Plan accordingly.

改文章摘至:https://msdn.microsoft.com/en-us/library/dn265018(v=vs.85).aspx

上一篇下一篇

猜你喜欢

热点阅读