Created
November 28, 2017 15:43
-
-
Save antlis/6b9492b88a4f0a0fb3ea1dd84f53eb18 to your computer and use it in GitHub Desktop.
tel links callto fallback
This file contains 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
$('a[href^=\'tel:\']').each(function() { | |
var target = 'call-' + this.href.replace(/[^a-z0-9]*/gi, ''); | |
var link = this; | |
// load in iframe to supress potential errors when protocol is not available | |
$('body').append('<iframe name="' + target + '" style="display: none"></iframe>'); | |
link.target = target; | |
// replace tel with callto on desktop browsers for skype fallback | |
if (!navigator.userAgent.match(/(mobile)/gi)) { | |
link.href = link.href.replace(/^tel:/, 'callto:'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment