Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is tagged through jQuery so I'm going to use jQuery; even though it's not mentioned in the question body.</p> <p>a) It sounds like you want to get the height of the viewport (window); which can be retrieved like this:</p> <pre><code>var height = $(window).height(); </code></pre> <p>If the height of the document (page) exceeds the height of the window, and there are no CSS properties blocking the display of scrollbars, then scrollbars will indeed by visible.</p> <pre><code>if( $(document).height() &gt; $(window).height() ) </code></pre> <p>b) This is going to be a bit trickier, in the sense the only way off the top of my head is to query every DOM element.. <strong>this is not a elegant solution</strong>; and <em>in fact I'd ask you to reconsider your approach if you really you must do this</em>. That said.. for curiosity...</p> <p>If you're looking for the max height, in the sense of the largest element - then this would work:</p> <pre><code>// Get height of largest element. var max_height = 0; $('*').each( function(){ // skip &lt;html&gt; and &lt;body&gt; if( ( $(this).get(0) == $('body').get(0) ) || ( $(this).get(0) == $('html').get(0) ) ) return; var current_height = $(this).height(); if( current_height &gt; max_height ) max_height = current_height; }); </code></pre> <p>For example, running that on this page...</p> <pre><code>&gt; console.log( max_height ); 570 </code></pre> <p>However, I'm not sure if you want the maximum height of all combined elements.. In which case we obviously need to add all the elements up, but there's the obvious problem: elements are nested!</p> <p>If this is what you want, then by using <code>.children()</code> we can just iterate through the lengths of the elements that are immediate children of your containing element/body.</p> <pre><code>// Get height of all combined elements var combined_height = 0; $('body').each( function(){ // replace with containing element? combined_height = combined_height + jQuery(this).height(); }); </code></pre> <p>For example, running that on this page:</p> <pre><code>&gt; console.log(combined_height); 2176 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload