Skip to content

Instantly share code, notes, and snippets.

@harrypujols
Last active October 10, 2015 03:47
Show Gist options
  • Save harrypujols/3627453 to your computer and use it in GitHub Desktop.
Save harrypujols/3627453 to your computer and use it in GitHub Desktop.
Hide my phone from bots
$(function() {
var p = 'tel';
var h = '1';
var o = '212'
var n = '555'
var e = '1973';
//activates the link if it's clicked from a phone
if( navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPod/i)
){
$('li.phone').replaceWith('<li><a href='+p+':'+h+o+n+e+'>Phone</a></li>');
}
//if the link is clicked from a desktop
else {
$('li.phone').replaceWith('<li><a href=\"#\">'+o+'-'+n+'-'+e+'</a></li>');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment