When the href of link A in IE6 is javascript protocol the current page does not jump

  • 2020-03-30 03:14:27
  • OfStack

There are several advantages to sometimes replacing buttons with links A when cutting pages

There is a hand effect by default when the mouse is over (no need to add cursor:pointer)
You can add pseudo-classes that are supported by both versions of IE

If the page is to refresh as a whole when clicked, IE6 is not satisfactory, as shown below
 
<p><a href="javascript:;" onclick="jumpSina()">Sina</a></p> 
<p><a href="javascript:void 0;" onclick="jumpSohu()">Sohu</a></p> 
<script> 
function jumpSina() { 
location.href = 'http://www.sina.com.cn' 
} 
function jumpSohu() { 
location.href = 'http://www.sohu.com' 
} 
</script> 

Click the link in IE6 cannot jump, other browsers can. The solution is to change the anchor,
 
<p><a href="###" onclick="jumpSina()">Sina</a></p> 
<p><a href="#none" onclick="jumpSohu()">Sohu</a></p> 
<script> 
function jumpSina() { 
location.href = 'http://www.sina.com.cn' 
} 
function jumpSohu() { 
location.href = 'http://www.sohu.com' 
} 
</script> 

If you change the jump mode to window.open, there is no problem under IE6, as follows
 
<p><a href="javascript:;" onclick="jumpSina()">Sina</a></p> 
<script> 
function jumpSina() { 
window.open( 'http://www.sina.com.cn') 
} 
</script> 

Related articles: