Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (54 sloc) 4.01 KB
<!DOCTYPE html>
<!--
GitHub: HenriqueIni
https://www.blogcyberini.com/
-->
<html>
<head>
<meta charset="utf-8">
<title>Botão de e-mail</title>
<!--
A imagem do botão está em Base64 e foi obtida no IconFinder (https://www.iconfinder.com/icons/764976/mail_media_social_square_icon)
Se preferir, coloque este CSS num arquivo externo.
-->
<style>
.mail-share-button{
display: inline-block;
width: 40px;
height: 40px;
margin: 5px;
background-size: 100% 100%; /* ou 'contain' */
background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA%2FPjxzdmcgaGVpZ2h0PSI2MHB4IiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA2MCA2MCIgd2lkdGg9IjYwcHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48dGl0bGUvPjxkZXNjLz48ZGVmcy8%2BPGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBpZD0ic29pY2FsIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSI%2BPGcgaWQ9InNvY2lhbCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTg3My4wMDAwMDAsIC02MzguMDAwMDAwKSI%2BPGcgaWQ9InNsaWNlcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTczLjAwMDAwMCwgMTM4LjAwMDAwMCkiLz48ZyBmaWxsPSIjMzQ5OERCIiBpZD0ic3F1YXJlLWZsYXQiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDE3My4wMDAwMDAsIDEzOC4wMDAwMDApIj48cG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tYWlsIi8%2BPC9nPjwvZz48L2c%2BPC9zdmc%2B"); /*Base 64 Icon by Xinh Studio*/
background-repeat: no-repeat;
background-position: center;
}
</style>
</head>
<body>
<a href="" id="mail-share-btt" rel="nofollow" target="_blank" class="mail-share-button"></a>
<!-- Você pode colocar este script num arquivo externo -->
<script type="text/javascript">
//Constrói a URL depois que o DOM estiver pronto
document.addEventListener("DOMContentLoaded", function() {
var url = window.location.href; //url
var title = encodeURIComponent(document.title); //título
var mailToLink = "mailto:?subject="+title;
//tenta obter o conteúdo da meta tag description
var desc = document.querySelector("meta[name='description']");
desc = (!!desc)? desc.getAttribute("content") : null;
//se a meta tag description estiver ausente...
if(!desc){
//...tenta obter o conteúdo da meta tag og:description
desc = document.querySelector("meta[property='og:description']");
desc = (!!desc)? desc.getAttribute("content") : null;
}
//Se houver descrição, combina a descrição com a url
//senão o corpo da mensagem terá apenas a url
var body = (!!desc)? desc + " " + url : url;
//altera o link do botão
mailToLink = mailToLink + "&body=" + encodeURIComponent(body);
document.getElementById("mail-share-btt").href = mailToLink;
}, false);
</script>
</body>
</html>
You can’t perform that action at this time.