Last active
April 13, 2017 00:36
-
-
Save roatnek/2e64bfdc80cc072133f172289cc3794b to your computer and use it in GitHub Desktop.
telな機能を持たないデバイスではtelリンクを無効化する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Depending on jQuery and UAParser.js | |
function disablePhoneLink() { | |
var device_type = new UAParser().getDevice().type; | |
var is_not_mobile = !(device_type == 'mobile' || device_type == 'tablet'); | |
if (is_not_mobile) { | |
$('a[href^="tel:"]').each(function() { | |
$(this).addClass('is-disabled') | |
.on('click', function(event) { event.preventDefault(); }); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment