Html 禁用 Lync Click to Call 检测网页中的号码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6728521/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 09:36:57  来源:igfitidea点击:

Disable Lync Click to Call detecting numbers in a web page

htmlinternet-explorerlync

提问by Peter

Is there a way to stop Microsoft Lync from detecting phone numbers in a web page, and adding its click to call icon to that phone number in Internet Explorer?

有没有办法阻止 Microsoft Lync 检测网页中的电话号码,并将其单击呼叫图标添加到 Internet Explorer 中的该电话号码?

Obviously the client can disable this functionality in Internet Explorer, however I would like to disable this for all who visit a particular website, as it is not playing nicely with embedded fonts in use on the website.

显然,客户端可以在 Internet Explorer 中禁用此功能,但是我想为所有访问特定网站的人禁用此功能,因为它不能很好地与网站上使用的嵌入字体配合使用。

To do this for Skype I would add the following meta tag into my web page's header:

要为 Skype 执行此操作,我会将以下元标记添加到我的网页标题中:

<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />

Thanks,

谢谢,

Peter

彼得

回答by CBono

I've found a few options, but none are as simple or clean as adding a META tag to the page (which Microsoft absolutely should give us as an option).

我找到了一些选项,但没有一个像向页面添加 META 标记一样简单或干净(微软绝对应该给我们一个选项)。

Option #1: Insert markup into your phone number

选项#1:在您的电话号码中插入标记

Adding something like a blank SPANinto the middle of a phone number is sufficient to throw off Lync's detection. This is a highly manual option, as it requires you to edit every phone number on a page. But it could be handy for disabling one or two numbers on a page, while allowing any others to be detected.

SPAN电话号码中间添加类似空白的内容就足以摆脱 Lync 的检测。这是一个高度手动的选项,因为它需要您编辑页面上的每个电话号码。但它可以方便地禁用页面上的一两个数字,同时允许检测任何其他数字。

<p>For help, please call 1-<span></span>800-555-1234.</p>


Option #2: Script away the additional markup

选项#2:脚本化附加标记

Lync appears to format phone numbers in a very predictable way. It wraps a SPANaround the number using a (as far as I can tell) consistent class name, then appends an Aanchor which contains the dialing icon.

Lync 似乎以一种非常可预测的方式格式化电话号码。它SPAN使用(据我所知)一致的类名将数字包裹起来,然后附加一个A包含拨号图标的锚点。

<!-- Lync formatting -->
<p>For help, please call
  <span class="baec5a81-e4d6-4674-97f3-e9220f0136c1" style="white-space: nowrap;">
    1-800-555-1234 
    <a title="Call: 1-800-555-1234" style="...">
      <img title="Call: 1-800-555-1234" src="data:image/png;base64,..."/>
    </a>
  </span>
.</p>

Given that very unique Guid used for the classname, you can target that with your own client script and hide it or do whatever. A jQuery approach to hide all Lync icons might look like:

鉴于用于类名的非常独特的 Guid,您可以使用自己的客户端脚本将其作为目标并将其隐藏或执行任何操作。隐藏所有 Lync 图标的 jQuery 方法可能如下所示:

$("span.baec5a81-e4d6-4674-97f3-e9220f0136c1 > a").hide();

UPDATE! Option #2a: Style away the additional markup

更新!选项#2a:样式去掉额外的标记

Using the same technique as the script example above, you can simply style away the offending anchor tag using CSS. This should be preferable to a script-based solution.

使用与上面的脚本示例相同的技术,您可以使用 CSS 简单地去除有问题的锚标记。这应该比基于脚本的解决方案更可取。

span.baec5a81-e4d6-4674-97f3-e9220f0136c1 > a {
   display: none !important;
}


Option #3: Use a TELanchor as a preemptive strike

选项#3:使用TEL锚作为先发制人的打击

There is a standardized wayto markup a phone number for compatibility with VOIP/dialing programs. It uses a standard Aanchor with a tel:protocol. This has the dual effect of not only disabling Lync's intrusive markup, but also providing better support for anything that knows how to dial a number (Skype) and mobile devices (both iOS and Android).

有一种标准化的方法来标记电话号码以与 VOIP/拨号程序兼容。它使用A带有tel:协议的标准锚点。这具有双重效果,不仅可以禁用 Lync 的侵入性标记,还可以为知道如何拨打号码 (Skype) 和移动设备(iOS 和 Android)的任何设备提供更好的支持。

<p>For help, please call <a href="tel:1-800-555-1234">1-800-555-1234</a>.</p>

Now Lync users can still click the link, which will prompt them to "open" it with Lync, regardless of the browser they use (I've confirmed compatibility with IE9, Firefox and Chrome). This strikes me as the best of both worlds: compatibility with users' telephony application, without trouncing all over your markup and layout.

现在,Lync 用户仍然可以单击该链接,这将提示他们使用 Lync“打开”它,而不管他们使用什么浏览器(我已经确认与 IE9、Firefox 和 Chrome 兼容)。这让我觉得是两全其美:与用户的电话应用程序兼容,而不会破坏您的标记和布局。



Until Microsoft comes up with a META tag to solve these issues, we've opted for #3.

在微软提出解决这些问题的 META 标签之前,我们选择了#3。



UPDATE:Incorporated the suggestion from @marsman57for improvement to CSS option #2

更新:合并了来自@marsman57建议以改进 CSS 选项 #2

回答by Brandon Barkley

I have suggested an edit to option #2, but until it is approved, I'll go ahead and drop this here. The reason for user2200197's problem is that the !important tag needs to be specified because the anchor tag specifies a display value that overrides it otherwise.

我已经建议对选项 #2 进行编辑,但在获得批准之前,我会继续将其放在此处。user2200197 的问题的原因是需要指定 !important 标签,因为锚标签指定了一个显示值,否则会覆盖它。

span.baec5a81-e4d6-4674-97f3-e9220f0136c1 > a {
   display: none !important;
}

回答by mhu

I've found the following regular expressions (on this blog) which the Lync plugin seems to use:

我发现了Lync 插件似乎使用的以下正则表达式(在此博客上):

(\+?1[\-\. ])?(\(\d{3}\)|\d{3})[\-\. ]?\d{3}[\-\. ]?\d{4})
((\+?1[\-\. ])?(\((800|880|888|877|866|855|844|900)\)|(800|880|888|877|866|855|844|900))[\-\.0-9A-Za-z]{7,9})
(\+\d+[\-\. ](\(\d+\)[\- ]?)?\d[\d\-\. ]+\d)
((x|X)\d{3,5})

So using &nbsp;or &dash;should prevent Lync from detecting the numbers.

因此,使用&nbsp;&dash;应阻止 Lync 检测数字。

回答by user2200197

I was unable to get Option 2 to work. I think this is because the add-on is triggered after the page is loaded. So that got me to thinking... If I trigger this after 5 seconds of the page loading, then hide the elements. This theory proved successfull, but it hid the phone number too.

我无法让选项 2 工作。我认为这是因为加载项是在页面加载后触发的。所以这让我开始思考......如果我在页面加载 5 秒后触发它,然后隐藏元素。这个理论被证明是成功的,但它也隐藏了电话号码。

I took it a step further and rebuilt the element for the Lync Click to Call class after stripping out the phone number. My steps may be crude, but effective.

我更进一步,在去掉电话号码后重建了 Lync Click to Call 类的元素。我的步骤可能很粗糙,但很有效。

    var ie = (document.all) ? true : false;

    function hideClass(objClass){
     //  This function will hide Elements by object Class
     //  Works with IE and Mozilla based browsers

    var elements = (ie) ? document.all : document.getElementsByTagName('*');
       for (i=0; i<elements.length; i++){
         //Loop through the elements until it finds one with the correct class name
         if (elements[i].className==objClass){
           //Extract the phone number from the element
           strPhone = getPhone(elements[i].innerHTML);
           //Replace the element with the phone number
           elements[i].outerHTML = "<SPAN class='baec5a81-e4d6-4674-97f3-e9220f0136c1'>"+strPhone+"</SPAN>"
         }
       }
     }
     function getPhone(thisStr){
        newStr = "";
        for (n=0; n<thisStr.length; n++){
            currChar = thisStr.substr(n,1)
            //Loop Through until it hits the first tag opening
            if (currChar != "<"){
                newStr+=currChar
            }else{
                break;
            }
        }
        return newStr;
     }

     function viewHTML(){
        alert(document.body.innerHTML)
     }

     function startTimer(){
        // 5 Seconds after the page loads, run the 
        window.setTimeout(function(){hideClass('baec5a81-e4d6-4674-97f3-e9220f0136c1');},5000);
     }
     window.onload=startTimer();

回答by chetan92

I found a useful snippet to remove the Lync Call sign here. It replaces the hyphen in the phone number with a similar looking character, and it is no longer identified as a phone number.

我在这里找到了一个有用的片段来删除 Lync 呼号。它将电话号码中的连字符替换为类似的字符,并且不再被识别为电话号码。