Open In App
Related Articles

How to add WhatsApp share button in a website using JavaScript ?

Like Article
Save Article
Report issue

WhatsApp is the most popular messaging app. This article describes how you can add the WhatsApp share button to your website. In this example we make a simple website that uses a Whatsapp share button when you click on it will open on the Whatsapp app on your system and your message was already printed there.

Note: This will work only with WhatsApp installed in your system (desktop/laptop)

Example: Create a simple webpage using the function, Sharing will be done when the user clicks on its button.


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href=
        button {
            width: 170px;
            height: 50px;
            background-color: #4ECC5B;
            color: #fff;
            border: 1px solid white;
            font-size: 1rem;
            cursor: pointer;
        button:hover {
            background-color: #3ae04b;
        <nav class="navbar background">
            <ul class="nav-list">
                <div class="logo">
                    <img src=
        <section class="section">
            <div class="box-main">
                <div class="firstHalf">
                    <h1 class="text-big">
                        7 Best Tips To Speed Up Your
                        Job Search in 2022
                    <p class="text-small">
                        Hunting down a relevant job requires
                        proper techniques for showcasing your
                        potential to the employer. <br> But with
                        the advent of COVID-19, it has become
                        a bit challenging and competitive to
                        reach out for your dream job. <br> Many
                        individuals have lost their jobs
                        during these times, and on the other
                        hand, freshers are facing difficulties
                        while applying for a new job. <br> But
                        there is no need for panic, you can
                        change your ways and streamline things
                        in a way that you get a proper result.
                    <button class="fab fa-whatsapp" 
                        Share on Whatsapp
<script type="text/javascript">
    function whatsapp() {
('whatsapp://send?text=Hello folks, GeekforGeeks giving 40% Off on DSA course')



Last Updated : 09 Feb, 2022
Like Article
Save Article
Share your thoughts in the comments
Similar Reads