BUG: Frame SRC Property Not Updated when Navigate Method Invoked (206652)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5

This article was previously published under Q206652

SYMPTOMS

The SRC property on a frame element in an HTML window does not appear to change as that frame is navigated to other pages, unless it is changed directly from script.

RESOLUTION

To accurately determine the current URL of a document inside a frame, script code should use the window.location.href property of that frame's window object. Cross-frame scripting rules apply.

STATUS

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

MORE INFORMATION

Steps to Reproduce Behavior

Use the following test files:

FRAMESRC.HTML
<HTML><HEAD><TITLE>Frame SRC Problem Replicator</TITLE>
<FRAMESET COLS="50%,*">
	<FRAME ID="Blank" SRC="about:blank" SCROLLING=NO NORESIZE>
	<FRAME ID="Doc" SRC="DocOne.html" SCROLLING=NO NORESIZE>
</FRAMESET>
</HEAD></HTML>
				
DOCONE.HTML
<HTML><BODY>
Doc One<P>
<INPUT TYPE="BUTTON" NAME=btnSrc VALUE="Show SRC"><P>
<INPUT TYPE="BUTTON" NAME=btnNav VALUE="Navigate to DocTwo"><P>
<A HREF="DocTwo.html">Show Doc Two</A>
<SCRIPT LANGUAGE="VBScript">	
	Sub btnSrc_onClick()
		msgBox parent.document.all("Doc").src
	End Sub
	Sub btnNav_onClick()
		window.navigate "DocTwo.html"
	End Sub
</SCRIPT>
</BODY></HTML>
				
DOCTWO.HTML
<HTML><BODY>
DocTwo<P>
<INPUT TYPE="BUTTON" NAME=btnSrc VALUE="Show Src"><P>
<INPUT TYPE="BUTTON" NAME=btnNewSrc VALUE="Set SRC to DocThree">
<SCRIPT LANGUAGE="VBScript">
	Sub btnSrc_onClick()
		msgBox parent.document.all("Doc").src
	End Sub
	
	Sub btnNewSrc_onClick()
		parent.document.all("Doc").src = "DocThree.html"
	End Sub
</SCRIPT>
</BODY></HTML>
				
DOCTHREE.HTML
<HTML><BODY>
DocThree<P>
<INPUT TYPE="BUTTON" NAME=btnSrc VALUE="Show src">
<SCRIPT LANGUAGE="VBScript">
	Sub btnSrc_onClick()
		msgBox parent.document.all("Doc").src
	End Sub
</SCRIPT>
</BODY></HTML>
				
The example frameset allows navigation through a series of three pages in the right-hand frame. In any page, the current value of the SRC property on the frame element can be viewed by clicking the Show SRC button.

When navigating between pages using any of the following methods, the SRC property is not updated to reflect the location of the new document in the right-hand frame:
  • Hyperlinking via an anchor tag inside the frame
  • Scripting a navigation using window.navigate (works under 5.5 - see the note to follow)
  • Scripting a navigation using location.href
  • Using the Back and Forward buttons
In Internet Explorer 5.5, window.navigate will work as expected: that is, the SRC property will be set to "doctwo.html". However, navigating with the Forward and Back buttons will still not update SRC. Changing the SRC property of the frame element directly, as in DOCTWO.HTML in the example, is the only way to update the frame element's SRC property reliably during a navigation.


Modification Type:MajorLast Reviewed:10/16/2002
Keywords:kbBug kbDHTML KB206652