The document.open Method with Replace Does Not Work in Frameset

Article translations Article translations
Article ID: 318382
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

Symptoms

When you call the document.open method with the replace parameter from a frameset, the document is not removed from the history. Therefore, if you go back in the navigation stack, you are returned to the previous document.

Resolution

To resolve this problem, obtain the latest service pack for Internet Explorer 6. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
328548 How to Obtain the Latest Internet Explorer 6 Service Pack
The English version of this fix should have the following file attributes or later:
   Date         Time      Version        Size       File name
   ------------------------------------------------------------
   27-FEB-2002  12:42:50  6.0.2714.2700  2,754,048  Mshtml.dll
					

The update for this problem is included in the "March 28, 2002 Cumulative Patch for Internet Explorer."

Workaround

To work around this problem, use one of the following methods:
  • Use the innerHTML property to replace sections of the document instead of replacing all of the document.
  • Set the document.location.href property.
NOTE: If you call document.location.replace, you must set up a page for each page that you want to browse to.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Internet Explorer 6 Service Pack 1.

More information

Steps to Reproduce the Behavior

  1. In Notepad, create a new Hypertext Markup Language (HTML) file named Frameset.htm, and then add the following code to the file:
    <html>
    <frameset rows = "*,*">
    	<frame name = "frame1" src = "frame1.htm">
    	<frame name = "frame2" src = "frame2.htm">
    </frameset>
    </html>
    					
  2. In Notepad, create a new HTML file named Frame1.htm, and then add the following code to this file:
    <HTML>
    <BODY>
    <script language="javascript">
    function Replace()
    {
      top.frame2.document.open("text/html","replace");
      top.frame2.document.writeln("...is gone (document.open)");
      top.frame2.document.close();
    }
    
    function Workaround1()
    {
      top.frame2.document.location.replace("frame2a.htm");
    }
    
    function Workaround2()
    {
      top.frame2.document.body.innerHTML="...is gone";
    }
    </script>
    Repro<br>
    
    <button onclick= "Replace()">document.open(.., "replace")</button>
    <br><br>
    Workarounds<br>
    <button onclick= "Workaround1()">document.location.replace workaround</button>
    <br><br>
    <button onclick= "Workaround2()">innerHTML workaround</button>
    </BODY>
    </HTML>
    					
  3. In Notepad, create a new HTML file named Frame2.htm, and then add the following code to this file:
    <HTML>
    <BODY>
    Top Secret Information...
    </BODY>
    </HTML>
    					
  4. In Notepad, create a new HTML file named Frame2a.htm, and then add the following code to this file:
    <HTML>
    
    <BODY>
    ...is gone.
    </BODY>
    </HTML>
    					
  5. Browse to the Frameset.htm file in a new instance of Internet Explorer 6.0.
  6. Click the first button to call document.open(.., "replace"). Notice that the back arrow is enabled, which indicates that the new page did not replace the first history entry. Click Back to see the previous information.
  7. Click the other two buttons to demonstrate the workarounds.

Properties

Article ID: 318382 - Last Review: June 19, 2014 - Revision: 3.0
Keywords: 
kbnosurvey kbarchive kbhotfixserver kbqfe kbbug kbdhtml kbfix kbie600presp1fix kbnavigation kbie600sp1fix KB318382

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com