UK[ˈəʊpən] US[ˈoʊpən]

adj.Open, open; open, public; frank; with room for discussion

vt.& vi.(open) open; start; unfold; start

n.open; outdoor, wild; open space

vi.To open; to show, to appear

vt.Open; to open; to open for business; to unveil (a building)

Third person singular: opens Present participle: opening Past tense: opened Past participle: opened

javascript open() method syntax

Function:Open a new document and erase the contents of the current document.

Syntax: document.open(mimetype,replace)

##Parameters: mimetype Optional. Specifies the type of document being written. The default value is "text/html". replace Optional. When this parameter is set, it causes new documents to inherit history entries from the parent document.

##Description:

This method will erase the content of the current HTML document and start a new document. The new document is written with the write() method or writeln() method.

Note:

After calling the open() method to open a new document and using the write() method to set the document content, you must remember to use the close method to close the document and force its content display. A script or event handler that is part of an overwritten document cannot call this method because the script or event handler itself will also be overwritten.

javascript open() method example

<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
function createNewDoc()
  {
  var newDoc=document.open("text/html","replace");
  var txt="<html><body>学习 DOM 非常有趣!</body></html>";
  newDoc.write(txt);
  newDoc.close();
  }
</script>
</head>

<body>
<input type="button" value="打开并写入一个新文档" onclick="createNewDoc()">
</body>

</html>

Run instance »

Click the "Run instance" button to view the online instance