open
Method of dom/Documentdom/Document
Syntax
var object = object.open(url, name, features, replace);
Parameters
url
- Data-type
- any
name
- Data-type
- BSTR
Note The following applies only if this method is used instead of window.open.
features
- Data-type
- BSTR
Note The following applies only if this method is used instead of window.open.
replace
- Data-type
- any
Return Value
Returns an object of type DOM NodeDOM Node
Object
document
Examples
The following example shows how to use the open method to replace the current document with a new document and display the HTML markup contained in the variable sMarkup.
<html>
<head>
<title>First Document</title>
<script>
function replace(){
var oNewDoc = document.open("text/html", "replace");
var sMarkup = "<html><head><title>New Document</title></head><body>Hello, world</body></html>";
oNewDoc.write(sMarkup);
oNewDoc.close();
}
</script>
</head>
<body>
<h1>I just want to say</h1><br>
<!--Button will call the replace function and replace the current page with a new one-->
<input type ="button" value = "Finish Sentence" onclick="replace();">
</body>
</html>
Notes
Remarks
When a function fired by an event on any object calls the open method, the window.open method is implied.
<script language="JScript">
function myOpen() {
open('about:blank');}
</script>
<body onclick="myOpen();">
Click this page and window.open() is called.
</body>
Syntax
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.5
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 3.4.1
See also
Related pages
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]