Microsoft KB Archive/206652

= BUG: Frame SRC Property Not Updated when Navigate Method Invoked =

Article ID: 206652

Article Last Modified on 10/16/2002

-

APPLIES TO


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

-



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.



Steps to Reproduce Behavior
Use the following test files:

FRAMESRC.HTML Frame SRC Problem Replicator      DOCONE.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 <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 <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.

Keywords: kbbug kbdhtml kbpending KB206652

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.