Get height of monitor in jQuery

screen.height

The screen.height property returns height of screen in pixels.

screen.availHeight

The availHeight property returns the height of the screen in pixels, minus interface features like the Windows taskbar, statusbar, menubars and titlebar.

screen.availHeight = (screen.height - height of taskbar)

$(window).height()

This method returns the height of browser viewport. If you minimize your browser then value of $(window).height() will change.

$(document).height()

This method returns the height of HTML document. If the actual document’s body height is less than the viewport height then it will return the viewport height instead.

$(document).height()

CODE
<!DOCTYPE html>
<html>
<head>
  <title>jQuery With Example</title>
  <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {
      $("#btnClick").click(function () {
        alert(screen.height);
        alert(screen.availHeight);
        alert($(window).height());
        alert($(document).height());
      });
    });
  </script>
</head>
<body>
  <input type="button" id="btnClick" value="Click" />
</body>
</html>
DISPLAY

3 comments :