Javascript DOM HTML Document open() Method with parameters

Introduction

Click the button to open an output stream, add some text, and close the output stream.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/* w  w  w  .ja  va 2s.co m*/
  document.open("text/html", "replace");
  document.write("<html><body><p>Hello World!</p></body></html>");
  document.close();
}
</script>

</body>
</html>



PreviousNext

Related