Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>WhatsApp Link Generator</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f2f2f2;
- text-align: center;
- margin: 0;
- padding: 0;
- }
- .container {
- max-width: 400px;
- margin: 50px auto;
- padding: 20px;
- border: 1px solid #ccc;
- border-radius: 10px;
- background-color: #e6e6e6;
- }
- h2 {
- margin-bottom: 20px;
- color: #007bff;
- }
- label {
- display: block;
- font-weight: bold;
- margin-bottom: 10px;
- text-align: left;
- }
- select, input[type="text"] {
- width: 100%;
- padding: 10px;
- margin-bottom: 20px;
- border: 1px solid #ccc;
- border-radius: 5px;
- }
- .generate-btn {
- background-color: #007bff;
- color: #fff;
- border: none;
- padding: 10px 20px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- border-radius: 5px;
- cursor: pointer;
- transition: background-color 0.3s ease;
- }
- .generate-btn:hover {
- background-color: #0056b3;
- }
- .copy-btn {
- background-color: #4CAF50;
- color: #fff;
- border: none;
- padding: 5px 10px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 14px;
- border-radius: 3px;
- cursor: pointer;
- transition: background-color 0.3s ease;
- }
- .copy-btn:hover {
- background-color: #45a049;
- }
- #output {
- margin-top: 20px;
- font-size: 18px;
- word-wrap: break-word;
- background-color: #fff;
- padding: 10px;
- border-radius: 5px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h2>WhatsApp Link Generator</h2>
- <form>
- <label for="country_code">Country:</label>
- <select id="country_code" name="country_code" required>
- <option value="880">Bangladesh (+880)</option>
- <option value="91">India (+91)</option>
- <!-- Add more country options here -->
- </select>
- <label for="whatsapp_number">WhatsApp Number:</label>
- <input type="text" id="whatsapp_number" name="whatsapp_number" placeholder="1234567890" required>
- <button type="button" class="generate-btn" onclick="generateWhatsAppLink()">Generate WhatsApp Link</button>
- </form>
- <div id="output"></div>
- </div>
- <script>
- function generateWhatsAppLink() {
- const country_code = document.getElementById('country_code').value;
- const whatsapp_number = document.getElementById('whatsapp_number').value;
- // Remove any non-numeric characters from the input
- const clean_whatsapp_number = whatsapp_number.replace(/\D/g, '');
- // Generate the WhatsApp link
- const baseUrl = 'https://api.whatsapp.com/send?phone=';
- const finalUrl = baseUrl + country_code + clean_whatsapp_number;
- // Display the generated link and copy button
- const outputElement = document.getElementById('output');
- outputElement.innerHTML = `<input type="text" value="${finalUrl}" id="finalUrl" readonly><button class="copy-btn" onclick="copyLinkToClipboard()">Copy</button>`;
- }
- function copyLinkToClipboard() {
- const linkElement = document.getElementById('finalUrl');
- linkElement.select();
- document.execCommand('copy');
- alert('Link copied to clipboard!');
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement