The window.open() method opens a new window, and the document.open() method opens a new document, in which you can use the write() or writeln() method to write content. Its syntax is:
oNewDoc = document.open (sMimeType[, sReplace]);
sMineType is a string that defines the MIME type. Navigator supports several different MIME types, but Internet Explorer currently only supports "text/html". The sMineType parameter is optional. The second parameter is also a string, which defines whether the new document being written should replace the current document's position in the history. If you want to achieve replacement, use the string "replace".
"replace" is basically used for windows that have empty documents or "about:blank" URLs. After "replace" is defined, the write() method can create HTML content in this window and replace the current URL's position in the history. If "replace" is not defined, the created HTML has its own historical position, and the user can click the back button to move forward until it is empty.
Look at the following script snippet:
var oNewDoc = document.open("text/html", "replace");
var sMarkup = "