Microsoft KB Archive/190244

= PRB: HREF="#" with Event Code Behaves Differently =

Article ID: 190244

Article Last Modified on 8/8/2007

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q190244



SYMPTOMS
The following HTML statement, when clicked, will navigate to a new URL in Internet Explorer 3.0, but fails to do so in Internet Explorer 4.0:  problem repro 



CAUSE
Internet Explorer 4.0 waits until all events from the  tag are finished before processing the HREF attribute, so window.location.href will be overwritten by HREF="#".



RESOLUTION
Here are three ways to make this tag work as expected in Internet Explorer 4.0. See the "More Information" section for a complete code listing.   Add this statement to the code: window.event.returnValue = false; This causes the onclick event to fire and not try to navigate to the HREF specified by the link.  Replace the HREF value with JavaScript:[code].  Eliminate HREF="#" and make it look like an anchor with Cascading Style Sheets (CSS) by adding this style attribute to the anchor: style="cursor:hand; text-decoration:underline; color:blue; font-family:times new roman" 



STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce Behavior
The following HTML code demonstrates the problem and the resolutions. <HTML> <HEAD> <TITLE> title </TITLE> </HEAD> <BODY>

 problem repro </A>  solution 1: add window.event.returnValue=false statement</A>  solution 2: replace HREF value with JavaScript:[code] </A>  solution 3: remove HREF attribute and use CSS </A> </BODY> </HTML>

<div class="references_section">