Advertisement
sakibalhasannaim

Whatsapp Link Generator Website Source Code

Jul 19th, 2023
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>WhatsApp Link Generator</title>
  5. <style>
  6. body {
  7. font-family: Arial, sans-serif;
  8. background-color: #f2f2f2;
  9. text-align: center;
  10. margin: 0;
  11. padding: 0;
  12. }
  13.  
  14. .container {
  15. max-width: 400px;
  16. margin: 50px auto;
  17. padding: 20px;
  18. border: 1px solid #ccc;
  19. border-radius: 10px;
  20. background-color: #e6e6e6;
  21. }
  22.  
  23. h2 {
  24. margin-bottom: 20px;
  25. color: #007bff;
  26. }
  27.  
  28. label {
  29. display: block;
  30. font-weight: bold;
  31. margin-bottom: 10px;
  32. text-align: left;
  33. }
  34.  
  35. select, input[type="text"] {
  36. width: 100%;
  37. padding: 10px;
  38. margin-bottom: 20px;
  39. border: 1px solid #ccc;
  40. border-radius: 5px;
  41. }
  42.  
  43. .generate-btn {
  44. background-color: #007bff;
  45. color: #fff;
  46. border: none;
  47. padding: 10px 20px;
  48. text-align: center;
  49. text-decoration: none;
  50. display: inline-block;
  51. font-size: 16px;
  52. border-radius: 5px;
  53. cursor: pointer;
  54. transition: background-color 0.3s ease;
  55. }
  56.  
  57. .generate-btn:hover {
  58. background-color: #0056b3;
  59. }
  60.  
  61. .copy-btn {
  62. background-color: #4CAF50;
  63. color: #fff;
  64. border: none;
  65. padding: 5px 10px;
  66. text-align: center;
  67. text-decoration: none;
  68. display: inline-block;
  69. font-size: 14px;
  70. border-radius: 3px;
  71. cursor: pointer;
  72. transition: background-color 0.3s ease;
  73. }
  74.  
  75. .copy-btn:hover {
  76. background-color: #45a049;
  77. }
  78.  
  79. #output {
  80. margin-top: 20px;
  81. font-size: 18px;
  82. word-wrap: break-word;
  83. background-color: #fff;
  84. padding: 10px;
  85. border-radius: 5px;
  86. }
  87. </style>
  88. </head>
  89. <body>
  90. <div class="container">
  91. <h2>WhatsApp Link Generator</h2>
  92. <form>
  93. <label for="country_code">Country:</label>
  94. <select id="country_code" name="country_code" required>
  95. <option value="880">Bangladesh (+880)</option>
  96. <option value="91">India (+91)</option>
  97. <!-- Add more country options here -->
  98. </select>
  99. <label for="whatsapp_number">WhatsApp Number:</label>
  100. <input type="text" id="whatsapp_number" name="whatsapp_number" placeholder="1234567890" required>
  101. <button type="button" class="generate-btn" onclick="generateWhatsAppLink()">Generate WhatsApp Link</button>
  102. </form>
  103. <div id="output"></div>
  104. </div>
  105.  
  106. <script>
  107. function generateWhatsAppLink() {
  108. const country_code = document.getElementById('country_code').value;
  109. const whatsapp_number = document.getElementById('whatsapp_number').value;
  110.  
  111. // Remove any non-numeric characters from the input
  112. const clean_whatsapp_number = whatsapp_number.replace(/\D/g, '');
  113.  
  114. // Generate the WhatsApp link
  115. const baseUrl = 'https://api.whatsapp.com/send?phone=';
  116. const finalUrl = baseUrl + country_code + clean_whatsapp_number;
  117.  
  118. // Display the generated link and copy button
  119. const outputElement = document.getElementById('output');
  120. outputElement.innerHTML = `<input type="text" value="${finalUrl}" id="finalUrl" readonly><button class="copy-btn" onclick="copyLinkToClipboard()">Copy</button>`;
  121. }
  122.  
  123. function copyLinkToClipboard() {
  124. const linkElement = document.getElementById('finalUrl');
  125. linkElement.select();
  126. document.execCommand('copy');
  127. alert('Link copied to clipboard!');
  128. }
  129. </script>
  130. </body>
  131. </html>
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement