How to Add a WhatsApp Button to Your Website or Blog

I made this simple code below to add a fixed WhatsApp button to any page. The script is not dependent on any external libraries and is easily configurable.

The code adds a div, which contains a link to an image, in this case, the WhatsApp logo. After adding these elements, it executes insertCss, which takes as its parameter the button's CSS. Finally, the function is executed addWhats, which calls the code above, and takes as its parameter the number, and optionally a predefined message.

Due to the simplicity of the code, it is easy to customize and easily integrated into any website, and can be customized to perform other functions such as Facebook Messenger, or email.

Below you can see an example of it working, I have html just a basic structure for demonstration, it is unnecessary to edit the html on any page where the script will be used.

Faithfully representing my position while writing this post, the photo is from:

unsplash-logoAnnie Spratt

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish