I met a location in IE6 today. href bug. in IE6, write href as javascript:; javascript: void (0); In tag a, and bind the onclick event to the tag, click and execute location. href implements page Jump, for example, the following code:
<A href = "javascitp:;" onclick = "toURL ()"> click to jump </a>
Or
<A href = "javascitp: void (0);" onclick = "toURL ()"> click to jump </a>
The code for the toURL function is as follows:
function toURL(){location.href = "http://js8.in";}
In this way, it can be used in non-IE6 browsers, but it cannot be redirected in IE6, and no error is reported. code after href, such as (alert (1);) is also executed.
Solution to location. href failure in IE6
In IE6, location. href is invalid because the href in tag a does not use javascript:; or javascript: void (0 );. The specific reason is unclear, but we can use href = "#" instead.
For example, the following code is normal in IE6:
<A href = http://www.js8.in/"###" onclick = "toURL ()"> normal redirect </a>
Another way is to set the href of tag a to "#" Through setAttribute in the toURL function, and then use location. href to redirect.
In addition, you can also solve the problem by getting the DOM node and binding the onclick event. For example, the following code:
var as = document.getElementsByTagName('a');for (var i=0;i<as.length;i++) { as[i].onclick=function() { window.location.href="http://www.js8.in"; return false; }}
Conclusion
IE6-the nightmare of the front-end is still going on.
I really don't want to say anything about IE6. This station is no longer in support of IE6, And I hope IE6 will exit the historical stage as soon as possible.