JavaScript Document Object : open() method

Description

The open() method of the document object opens a stream to collect the output of write() or writeln methods.

Version

Implemented in JavaScript 1.0

Syntax

document.open()
document.open(mimetype)

Parameter

mimetype : The type of contain in document. Default type : text/html.

Example of document Object : open() method

The following web document demonstrates how the open() method can be used.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JavaScript document Object - open() method</title>
</head>
<body>
<h1 style="color: red">JavaScript document Object : open() method</h1>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
mywin=window.open("") //Create a blank window
mywin.document.open() //open document stream
mywin.document.write("We are learning open() method")
mywin.document.close()
//]]>
</script>
</body>
</html>

View the example of document object's open method in the browser

Practice document object's open() method with Online Editor

Supported Browser

Internet Explorer 7,8 Firefox 3.6 Google Chrome 7 Safari 5.0.1 Opera 10
Yes No No No No

See also :

JavaScript Client side objects, methods, properties.

JavaScript Core objects, methods, properties.

Please Google+, Like this tutorial on FaceBook, Tweet, save it as bookmark and subscribe with our Feed. Have suggestions? comment using Disqus down this page. Thanks.


share with delicious share with facebook w3r rss  share with digg share with reddit share with stumbleupon share with twitter