Microsoft KB Archive/274586

= Internet Explorer 5.5 Reloads Page Instead of Scrolling When You Click an Anchor Targeting a Different Frame =

Article ID: 274586

Article Last Modified on 1/29/2007

-

APPLIES TO


 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q274586



SYMPTOMS
Internet Explorer 5.5 may reload a page instead of scrolling when you click an anchor that targets a different frame. For example, assume that you have a Web page that contains two frames: an upper frame and a lower frame. The upper frame contains several hyperlinks that point to the anchors in the lower frame. When you click the hyperlinks in the upper frame, the lower frame is reloaded instead of being scrolled (as in earlier versions of Internet Explorer). If the lower frame captures the &quot;onload&quot; event to perform initialization, the problem is magnified.



WORKAROUND
To work around this behavior, the Web page author can modify the upper frame by replacing the typical hyperlink with &quot;anchor.scrollIntoView&quot;. The following sample page demonstrates this method:

Original page: ...  ... 1-2.1 ... Modified page: ...  function ScrollTo(name) { top.bottomframe.document.anchors.item(name).scrollIntoView; } ... 1-2.1 ... Or, with a frameset declared as:    The left frame could navigate to an anchor by using the following code: Second

function handle_click {

var user_agent = window.navigator.userAgent var msie = user_agent.indexOf ( &quot;MSIE &quot; ) if ( msie > 0 ) { event_element = window.event.srcElement;

while (event_element.tagName != 'A') { event_element = event_element.parentElement; }

myelement = event_element.href; myhash = myelement.substring ( myelement.indexOf(&quot;#&quot;)+1, myelement.length);

parent.right.document.all(myhash).scrollIntoView; window.event.returnValue = false; }     else return true; } This script code functions as follows:
 * Obtain the user agent string to check for Internet Explorer as the browser.
 * Retrieve the source element for the click event.
 * Make sure that the source element is an Anchor tag. If it is not, retrieve the source element's parent element. This handles cases in which the text of the anchor is wrapped in a Font tag.
 * Parse the Href tag of the Anchor tag to remove the hash location.
 * Access the other frame and use scrollIntoView on the hash that was parsed.
 * Return False from the event. This prevents the anchor from navigating as well (because the code has handled the event).
 * The Else statement catches all other browser types and allows regular navigation through the Href tag.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="references_section">