This article describes the solution to the invalid window.location.href in IE6 browser. Share it for your reference. The specific methods are as follows:
window.location.href is a jump function in js. Many people will find that window.location.href cannot be jumped in ie6. Let me introduce the reasons and solutions to you below.
The problem code is as follows:
Copy the code as follows: <a href="javascript:void(0);" onclick="javascript:test();">Click to jump</a>
<script>
test = function(){
window.location.href = "//www.VeVB.COM";
}
</script>
The correct code is as follows:
Copy the code as follows: <a href="javascript:void(0);" onclick="javascript:test();return false;">Click to jump</a>
<script>
test = function(){
window.location.href = "//www.VeVB.COM";
}
</script>
reason:
return false so that the browser's events will not continue to bubble out, which inspires the browser's default events
Summarize
The principle is not that window.location.href is incompatible, but that our return false is behind it, so it cannot jump.
I hope this article will be helpful to everyone's JavaScript programming.