Javascript DOM HTML Document defaultView Property

Introduction

Get the document's window object:

var x = document.defaultView;

The defaultView property returns the current window object.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Get the window object</button>

<p id="demo"></p>

<script>
function myFunction() {//w  w  w .j  av  a 2  s . c o  m
  var x = document.defaultView;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The defaultView property returns the document's Window Object.




PreviousNext

Related