Last active
October 10, 2015 03:47
-
-
Save harrypujols/3627453 to your computer and use it in GitHub Desktop.
Hide my phone from bots
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() { | |
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