How not to let the picture open a new window?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    img{
        width:200px;
    }
    </style>
    <script>
    var n = 1;
    function changePic(m){
        return n = m;
    }

    function change(){
        var myImg = document.getElementsByTagName("img")[0];
        myImg.src = "images/0" + n + ".jpg";
        if(n<5)nPP;
        else n=1;
    }
    
    </script>
</head>
<body onload="setInterval(change,1000);">
    <img src="images/01.jpg" alt="" width="200">
    <div>
        <a href="images/01.jpg" onclick="changePic(1)"></a>
        <a href="images/02.jpg" onclick="changePic(2)"></a>
        <a href="images/03.jpg" onclick="changePic(3)"></a>
        <a href="images/04.jpg" onclick="changePic(4)"></a>
        <a href="images/05.jpg" onclick="changePic(5)"></a>
    </div>
</body>
</html>

the above code picture can be rotated. Every time you click on a, you will immediately jump to that picture, but there is a problem. You will open a new window and display the picture in the new window. How can you not open this window and display the picture in the original window?
none of the methods I have tried work
1. Add target= "_ self"
2 to each a. Modify

function changePic(m){
    var myImg = document.getElementsByTagName("img")[0];
    myImg.src = "images/0" + m + ".jpg";
    return n = m;
}
Apr.13,2021

three methods.

    Change the onclick of the
  1. an element to onclick= "changePic (1); return false;"
  2. )
  3. call event.preventDefault (); in the changePic function
  4. Change the href attribute of
  5. an element to "javascript:void (0);"

it is best to register the event with the parent element div.

Menu