<div class="share-buttons">
<button class="whatsapp-button" onclick="shareOnWhatsApp()">Share on WhatsApp</button>
<button class="facebook-button" onclick="shareOnFacebook()">Share on Facebook</button>
</div>
<style>
.share-buttons {
display: flex;
justify-content: space-around;
width: 100%;
margin-bottom: 20px; /* Add some margin if needed */
}
.whatsapp-button,
.facebook-button {
background-color: #25d366; /* WhatsApp Green */
color: #ffffff;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.facebook-button {
background-color: #1877f2; /* Facebook Blue */
}
</style>
<script>
function shareOnWhatsApp() {
let text = 'Check out this post: ' + window.location.href;
let url = 'https://api.whatsapp.com/send?text=' + encodeURIComponent(text);
window.open(url, '_blank');
}
function shareOnFacebook() {
let text = 'Check out this post: ' + window.location.href;
let url = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(window.location.href) + '"e=' + encodeURIComponent(text);
window.open(url, '_blank');
}
</script>
0 Comments