en mi html, hay un botón y abre el script de chat-bot.
funciona perfectamente en html.
pero no funciona en mi script.
... ... <section> <button type="button" onclick="javascript:calleoChat('startChat')">Try it</button> </section> <script> //button creation let btn = document.createElement("button"); btn.innerHTML = "Open Chat-Bot"; //call chat bot script, but it doesn't work btn.onclick = "javascript:calleoChat('startChat')"; node.appendChild(btn); //insert button to selected class document.getElementsByClassName("AddToBagButton__container")[0].appendChild(node); </script>Consulte mis códigos de muestra anteriores y deme su amable consejo para resolver este problema.
onclick="calleoChat('startChat')"
btn.onclick = calleoChat('startChat');
btn.addEventListener("click", () => calleoChat("startChat"));
Más información sobre eventos onclick: https://www.w3schools.com/jsref/event_onclick.asp