w3schools    w3Schools
Search :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
HTML DOM
DOM HOME
DOM Intro
DOM Nodes
DOM Node Tree
DOM Methods
DOM Node Access
DOM Node Info
DOM How To
DOM Events
DOM Reference
DOM Summary

DOM Examples
DOM Examples

DOM Objects
DOM Window
DOM Navigator
DOM Screen
DOM History
DOM Location

DOM Document

DOM Anchor
DOM Area
DOM Base
DOM Body
DOM Button
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM IFrame
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Meta
DOM Object
DOM Option
DOM Select
DOM Style
DOM Table
DOM TableCell
DOM TableRow
DOM Textarea

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

Browse Tutorials
 

HTML DOM open() Method


Document Object Reference 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, add some text, then close it

Open a new document in a new window and add some text


Document Object Reference Complete Document Object Reference