why should I click twice on a link to trigger onclick function

Viewed 26

In a project, I'm using a xmlhttp to query the db and return data. I pass this data in a link, Everything works file. But I have to click twice on the link to trigger the on click function. Any help please?!

 <script>
            function changeIframeSrc(link) {
                link = link.replaceAll(' ', '+', link);
                let newLink = "https://maps.google.com?q=" + link + "&output=embed";
                document.getElementById('iframe').src = newLink;
            }
        </script>
0 Answers
Related