Jquery gets the browser height, width, and scroll bar height

web front end nineteen thousand and thirty-six 13 years ago (2012-05-25)

We often need to obtain browser The width and height of, as well as the height of the scroll bar, are sorted out today and used directly in the future. Go to his X handwriting code.

Jquery code:
  1. alert($(window).height());   //Height of window viewing area at browser time   
  2. alert($(document).height());   //The height of the lower window document in the browser   
  3. alert($(document.body).height()); //Height of the lower window document body in the browser   
  4. alert($(document.body).outerHeight( true )); //The total height of the lower window document body in the browser includes the border padding margin   
  5. alert($(window).width());   //Browser current window viewing area width   
  6. alert($(document).width()); //Browser current window document object width   
  7. alert($(document.body).width()); //Height of the lower window document body in the browser   
  8. alert($(document.body).outerWidth( true )); //The total width of the lower window document body in the browser includes the border padding margin   
  9. alert($(document).scrollTop());   //Get the vertical height from the scroll bar to the top   
  10. alert($(document).scrollLeft());   //Gets the vertical width of the scroll bar to the left