13
I’ve always used window.location.href to redirect to another internal page or external URL, but when using only window.location (without the .href) produces the same result, i.e., makes the same redirect.
Example with window.location:
function redir(){
window.location = "./";
}
<button onclick="redir()">Ir</button>
Example with window.location.href:
function redir(){
window.location.href = "./";
}
<button onclick="redir()">Ir</button>
With this raised me the doubt: what is the difference between the two instructions and when to use one or the other?