Return to Snippet

Revision: 45528
at May 3, 2011 07:08 by diogoweb


Initial Code
<!DOCTYPE html>
<html>
<head>
 
  <script src="http://code.jquery.com/jquery-git.js"></script>

<script>
$(window).resize(function() {
	$("#test").text($(document).width() + " x " + $(document).height());
});
</script>
</head>
<body>
  <button id="getp">Get Paragraph Height</button>
  <button id="getd">Get Document Height</button>
  <button id="getw">Get Window Height</button>

  <div>&nbsp;</div>
  <p>
    Resize window
  </p>
<script>
    function showHeight(ele, h) {
      $("div").text("The height for the " + ele + 
                    " is " + h + "px.");
    }
    $("#getp").click(function () { 
      showHeight("paragraph", $("p").height()); 
    });
    $("#getd").click(function () { 
      showHeight("document", $(document).height()); 
    });
    $("#getw").click(function () { 
      showHeight("window", $(window).height()); 
    });

</script>
<div id="test"></div>
</body>
</html>

Initial URL


Initial Description


Initial Title
Get browser viewport

Initial Tags


Initial Language
jQuery