Good day! There was such a problem. Redirect does not work in js
& lt; a id = "aaa" onclick = "href ();" href = "#" & gt; & lt; / a & gt;
Tried these ways but nothing helps
& lt; script language = "JavaScript" & gt;
function href () {
window.location.replace ("http://stackoverflow.com");
document.location.href = 'http: //stackoverflow.com'
}
& lt; / script & gt;
Answer 1, authority 100%
The problem is that inline handlers are executed in the context of an HTML element.
that is, whatever is used is first searched for in the html element, and in this case href is a property of the a
element, not a function.
You can easily check it, just change the code to the following
& lt; a id = "aaa" onclick = "console.log (this.href = == href, href); " href = "#" & gt; Click me & lt; / a & gt;