How to prevent phone numbers to be converted into Skype links?

后端 未结 14 733
猫巷女王i
猫巷女王i 2020-12-13 02:08

On those Windows machines with Skype installed, it tends to convert all phone-formatted numbers to Skype links so you can click it in order to make a call on Skype.

14条回答
  •  情书的邮戳
    2020-12-13 02:32

    Try this. It substitutes spaces in the phone number with an invisible span + the original space char. So skype cannot understand it is a number and our beloved phone number stays the same :) I had to use this approach since I usually let the content administrator change phone numbers at his will therefore I could not use a hard coded number inside javascript. Of course your markup should look like your number with some spaces inside it.

    $(document).ready(function() {
        if ($(".phone_number").length>0) {
            $(".phone_number").each(function() {
                $(this).html($(this).html().replace(/\s/g,"_ "));
            });
        }
    });
    

提交回复
热议问题