javascript's document.open() does not use the "replace" flag quite as expected

NEW
Unassigned

Status

()

Core
DOM: Core & HTML
P5
normal
14 years ago
21 days ago

People

(Reporter: rob, Unassigned)

Tracking

1.0 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1

Javascript's document.open() function has two parameters. The first is the MIME
type (generally, "text/html") and the second indicates that the content to be
written should *replace* the current/original content of the page in the
browser's history.

Mozilla and Firefox do not completely ignore the 2nd parameter, however they
enter the page as a *new* entry in the history, allowing the user to page back
to the page as it originally was.

As is probably very annoying to mention, it works as expected in IE.

Reproducible: Always
Steps to Reproduce:
1) Page is opened. For ease of explanation of the history, let's say the user
double-clicked an html file on their hard drive and it opened in the browser.
2) The current page is rewritten using JavaScript and document.open() as
described above.
3) User navigates to some other page.
4) User clicks back button and sees the *rewritten* page.
Actual Results:  
User is able to click "Back" yet again and see the original page, the way it
looked before rewriting.

Expected Results:  
Back button is disabled, user is at the beginning of history and cannot go back
anymore.

This is very easy to reproduce. I can send you a standalone test page if desired.
document.open is DOM0 -> Core.
Assignee: firefox → general
Component: General → DOM: Level 0
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → 1.0 Branch
Actually, attaching a simple test case would probably help a bit.  Thanks!
Assignee: general → nobody
QA Contact: ian → general
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5

Comment 5

21 days ago
Seems like this has been fixed. The test case in comment #3 (reproduced below, resurrected from web.archive.org) is now working as expected.

<HTML>
<HEAD>
<TITLE>First Document</TITLE>
<script>
function replace(){
    var oNewDoc = document.open("text/html", "replace");
    var sMarkup = "<HTML><HEAD><TITLE>New Document</TITLE><BODY>Hello, world</BODY></HTML>";
    oNewDoc.write(sMarkup);
    oNewDoc.close();
}
</script>
</HEAD>
<BODY>
<h1>I just want to say</h1><br>
<!--Button will call the replace function and replace the current page with a new one-->
<Input type ="button" value = "Finish Sentence" onclick="replace();">
</BODY>
</html>
You need to log in before you can comment on or make changes to this bug.