Cannot be reversed in the current window?

<a href="" class="loginOut" onclick="logOut()"                 target="_self">
    <span class="btn"></span>
</a>

function logOut () {

window.location.href="login.html";

}
Why can"t I transfer it on the current page?

Apr.02,2021

add the full path


write the href in the a tag javascript:void (0) so that the default jump behavior of the a tag does not occur.
before, the page was directed to the current page (href is empty) because the jump did not start in the logOut () method.
that is

<a href="javascript:void(0)" class="loginOut" onclick="logOut()"                 target="_self">
    <span class="btn"></span>
</a>
Menu