How to disable link to phone number when on Desktop?

后端 未结 20 1017
清酒与你
清酒与你 2021-02-03 23:47

How can I add a phone number to a website that is clickable but hides the link when I\'m browsing on a website that doesn\'t support touch.

I could use Modernizr to set

20条回答
  •  深忆病人
    2021-02-04 00:18

    Thanks to TattyFromMelbourne's post I am now using a pretty simple bit:

    My button id="call" will make the phone call based on his "probablyphone" test function but also will scroll down to the contact info section either way giving the button a working use no matter what.

    I aslo replaced the alert with an empty function, to remove the pop-up.

    PHONE US
    
    
    $("#call").on('click', function() {
        var probablyPhone = ((/iphone|android|ie|blackberry|fennec/).test(navigator.userAgent.toLowerCase()) && 'ontouchstart' in document.documentElement);
        var link = "callto:15555555555";
            if ( !probablyPhone ) {
                window.alert = function() {};}              
        else{window.location.href = link;}
    });
        
    

提交回复
热议问题