Skip to content

Instantly share code, notes, and snippets.

@rmpel
Last active June 14, 2016 07:59
Show Gist options
  • Save rmpel/463af6566bc6d8ee0b41d10e5d1b23a1 to your computer and use it in GitHub Desktop.
Save rmpel/463af6566bc6d8ee0b41d10e5d1b23a1 to your computer and use it in GitHub Desktop.
block InternetExplorer <= 11 w/o Skype tel: links
(function(w) {
w.cantel = true; // set true for all browsers
if ("ActiveXObject" in w) { // if IE <= 11
w.cantel = false;
var activex;
try { activex = !!new ActiveXObject("Skype.Detection"); } catch (e) { activex = false; }; // test for skype
if (activex) {
w.cantel = true;
}
}
// cantel === IE+skype || MS.Edge || Other browser
if (!w.cantel) {
var onload = w.onload || function(){},
links = document.getElementsByTagName("a");
w.onload = function(){
onload();
var i, at;
for(i=0; i<links.length; i++) {
if ('tel:' == links[i].href.substr(0,4)) {
at = links[i].getAttribute('data-alt-href') || false;
if (at) {
links[i].href=at;
}
else {
links[i].onclick=function(){ return false; };
}
}
}
}
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment