1

Hello I'm trying to send msg on whatsapp.web, but it's not working I don't know where I'm going wrong

i want this:

 
 function getLinkWhastapp(number, message) {
  console.log("a");
  var url =
    "https://api.whatsapp.com/send?phone=" +
    number +
    "&text=" +
    encodeURIComponent(message);

  return url;
}

 document
    .querySelector("div.btn-simular button")
    .addEventListener("click", (e) => {
      var yourNumber = "558186580524";
      var yourMessage = "testing";
      getLinkWhastapp(yourNumber, yourMessage);
    });
            <div class="btn-simular">
              <button class="btn">
                Quero Contratar
              </button>
            </div>
Ming
  • 1,349
  • 4
  • 13
  • 36
  • I hope "558186580524" is not a real number – evolutionxbox Jul 15 '20 at 16:08
  • 55 is country / 73 is dd region / and others is numbers – Ming Jul 15 '20 at 16:09
  • My concern is that a real number has been given out on the internet. Consider replacing it with a fake number, please. – evolutionxbox Jul 15 '20 at 16:10
  • @evolutionxbox is false number i test with other number, but thank you for your concern – Ming Jul 15 '20 at 16:10
  • I tested it now, the link works, but for some reason it is not opening the whatsapp window when I click the button – Ming Jul 15 '20 at 16:18
  • Does this answer your question? [Clicking a link in mobile website should open whatsapp app](https://stackoverflow.com/questions/42832734/clicking-a-link-in-mobile-website-should-open-whatsapp-app) – imvain2 Jul 15 '20 at 16:24
  • 1
    If you're trying to send messages with whatsapp without user interaction, you're probably out of luck. that would be a serious security problem if it was allowed – user120242 Jul 15 '20 at 16:33

0 Answers0