HTML DOM close()
The DOM's close() function helps finish writing on a window. It shows that we're done writing. You don't need to give any extra information when using close().
Syntax:
document.close()
Example 1: Example of DOM close() method.
The DOM's close() function helps finish writing on a window. It shows that we're done writing. You don't need to give any extra information when using close().
Syntax:
document.close()
Example 1: Example of DOM close() method.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
h1,
h2 {
color: green;
}
</style>
</head>
<body>
<h1>Propertutorials</h1>
<h2>DOM close() Method</h2>
<button onclick="myfunc()">Submit</button>
<script>
// This function is called on submit, it opens
// a stream, write "PRACTICE" and then closes
// the stream.
function myfunc() {
document.open();
document.write(" < h1 > PRACTICE < /h1>");
document.close();
}
</script>
</body>
</html>