Function const openChat = phone => { const link = document.createElement("a"); link.setAttribute("href", `whatsapp://send?phone=${phone}`); document.body.append(link); link.click(); document.body.removeChild(link); }; Example usage openChat('972501234567')