Javascript code weird bug

Report
Posts
2
Registration date
Monday January 18, 2021
Status
Member
Last seen
February 20, 2021
-
Hi, I use a Javascript code to open a link in new tab when a button is clicked. I use this function:
<button  onclick="myFunction()">Open site</button>
<script>
function myFunction(){
  window.open("LINK");
}
</script>

The problem is there is a bug in links it open the wrong links like if I clicked the other button, it mixes the links. This happens if the codes are in the same page. I searched google for this probleme but i don't find. Any idea about this weird thing?
How can I put my buttons in home page without having this bug?

Thank you,

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!