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

This article was previously published under Q274586
This article has been archived. It is offered "as is" and will no longer be updated.
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 "onload" 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 "anchor.scrollIntoView". The following sample page demonstrates this method:

Original page:
...<head><base target="bottomframe"></head>...<a href="frame2.htm#2.1">1-2.1</a>...				
Modified page:
...<head><script lanaguage="JScript">function ScrollTo(name){  top.bottomframe.document.anchors.item(name).scrollIntoView();}  </script></head>...<a href="javascript:ScrollTo('2.1')">1-2.1</a>...				
Or, with a frameset declared as:
<frameset cols=50%,* id=frame1 name=frame1> <frame src="left_toc2.htm" id="left" name="left"></frame> <frame src="right_toc2.htm" id="right" name="right"></frameset>				
The left frame could navigate to an anchor by using the following code:
<A href="right_toc.htm#second" target="right" onclick="handle_click()">Second</A><script language=javascript>	function handle_click() {                var user_agent = window.navigator.userAgent                var msie = user_agent.indexOf ( "MSIE " )                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("#")+1, myelement.length);<BR/>	            parent.right.document.all(myhash).scrollIntoView();	            window.event.returnValue = false;                    }	  else return true; 	}</script>				
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.
Properties

Article ID: 274586 - Last Review: 10/21/2013 01:52:38 - Revision: 3.1

  • 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
  • kbnosurvey kbarchive kbprb kbprogramming KB274586
Feedback