Bug 4056

Summary: document.write in same function as window.open fails to write new content
Product: WebKit Reporter: Vicki Murley <vicki>
Component: DOMAssignee: Dave Hyatt <hyatt>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   

Description Vicki Murley 2005-07-18 13:32:25 PDT
This bug is also in Radar as <rdar://4179028>

Summary:
If an URL is specified while opening a new window using window.open(),
the initial markup does not clear off when we use document.write()
subsequently.

Steps to Reproduce:
1. Create a HTML file, using the following markup, and name it init.html :-
<html>
    <body>
        Ideally, this markup should get cleared.
    </body>
</html>

2. Create another HTML file called main.html, using the markup given below,
   in the same directory where you have saved init.html :- 
<html>
    <body>
        <script>
            function popup()
            {
                w = window.open(
                    "init.html"
                    ,"win2"
                    ,"Scrollbars=1,resizable=1,width=400,height=450"
                );
                w.document.open("text/html");
                w.document.write("<html>");
                w.document.write("<body>");
                w.document.write("New markup");
                w.document.write("</body>");
                w.document.write("</html>");
                w.document.close();
                w.focus();
            }
        </script>

        <a href="javascript:popup()">Click to open a new window</a>
    </body>
<html>

3. View the HTML file main.html in a Safari 1.3 browser.

4. Click on the link "Click to open a new window".

Expected Results:
A new window should appear with the text "New Markup".

Actual Results:
In Safari 1.3, a new window appears alright but the initial markup does not
get cleared. We see the text "Ideally, this markup should get cleared."

In other browsers e.g. Netscape 7.1, IE 5.5, IE 6, Firefox 1.0.4,
we get the expected result.

-------------------------------------------

<GMT14-Jul-2005 16:22:33GMT> 
works if a document.write is in a separate function
Comment 1 Geoffrey Garen 2005-07-29 14:39:03 PDT
Fixed.