Last active
June 14, 2016 07:59
-
-
Save rmpel/463af6566bc6d8ee0b41d10e5d1b23a1 to your computer and use it in GitHub Desktop.
block InternetExplorer <= 11 w/o Skype tel: links
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
(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