Created
March 27, 2013 15:46
-
-
Save jab416171/5255264 to your computer and use it in GitHub Desktop.
Automatically detects if a user is logged into gmail, and if they are, will replace all the mailto: links on your webpage with links to the gmail compose window (automatically filling in the To field):
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
$('<img/>').hide() | |
.attr('src','https://mail.google.com/mail/photos/img/photos/public/AIbEiAIAAABDCKa_hYq24u2WUyILdmNhcmRfcGhvdG8qKDI1ODFkOGViM2I5ZjUwZmZlYjE3MzQ2YmQyMjAzMjFlZTU3NjEzOTYwAZwSCm_MMUDjh599IgoA2muEmEZD') | |
.load(function(){ | |
$('a[href^="mailto:"]').each(function(){ | |
var email = $(this).attr('href').replace(/^mailto:/,''); | |
$(this).attr('href','https://mail.google.com/mail/?view=cm&fs=1&tf=0&to='+escape(email)); | |
}); | |
}) | |
.appendTo('body'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment