|
HTML DOM open() Method
Complete Document Object Reference
Definition and Usage
The open() method opens a stream to collect the output from any
document.write or document.writeln methods.
Note: If a document already exists in the
target, it will be cleared. If this method has no arguments, a new window
with about:blank is displayed.
Syntax
|
document.open(mimetype,replace)
|
| Parameter |
Description |
| mimetype |
Optional. Specifies the type of document you are writing
to. Default value is "text/html" |
| replace |
Optional. When set, it causes the history entry for the new
document to inherit the history entry from the parent document |
Example
<html>
<head>
<script type="text/javascript">
function createNewDoc()
{
var newDoc=document.open("text/html","replace");
var txt="<html><body>Learning about the DOM is FUN!</body></html>";
newDoc.write(txt);
newDoc.close();
}
</script>
</head>
<body>
<input type="button" value="Write to a new document"
onclick="createNewDoc()">
</body>
</html>
|
|
Try-It-Yourself Demos
Open a
new document in a new window and add some text
Complete Document Object Reference
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 3500 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|