Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

Whatsapp link - dynamic link for share

0 votes
47 views
added Jan 12 in Software & tools by lcjr First Warrant Officer (8,030 points)
edited Jan 12 by lcjr
$('#whatsappBtn').click(function(){
  var whatsAppPhone = '60123456789',
      whatsappPhone2 = '601233445566'; 
  var defaultMessage = "";
  var url = window.location.href;
  if(url.includes('1860554')) {
    defaultMessage = "1860554 message goes here:";
  } else if(url.includes('1901663')) {
    defaultMessage = "whatsappPhone2 message goes here:";
  }
    else {
    defaultMessage = "Default message goes here:";
  } 

  if(url.includes('1901663')) {
    window.open(
      "https://wa.me/"+whatsappPhone2+"?text="+defaultMessage+" "+window.location.href,
      '_blank',
    );

  } else {
    window.open(
      "https://wa.me/"+whatsAppPhone+"?text="+defaultMessage+" "+window.location.href,
      '_blank',
    );
  }
  // window.open(
  //   "https://wa.me/"+whatsAppPhone+"?text="+defaultMessage+" "+window.location.href,
  //   '_blank',
  // );
});

 

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...