title: How do I constrain the size of a tooltip/popup-style DIV so that it doesn't trigger scrollbars on the page
body: <p>The mouse hovers over an element and a tip appears.   The tip overflows the page, triggering a scrollbar, which changes the layout just enough so that the underlying element that triggered the tip is no longer under the mouse pointer, so the tip goes away.</p>
  
  <p>The tip goes away, so the scrollbar goes away, and now the mouse is again over the element.</p>
  
  <p>Wash, rinse, repeat.</p>
  
  <p>If I could make sure that tip isn't too big so as to trigger scrollbars, that would solve my problem.</p>
  
  <p>EDIT: After reading comments, some things to clarify:
  The div contains text which can vary.   If I can, I want to show all the text.   The div's location needs to be near the element the mouse's tip is over.   So the key is, I need to know whether to truncate the text.</p>
  
  <p>I did find this link:<br>
  <a href="http://www.howtocreate.co.uk/tutorials/javascript/browserwindow" rel="nofollow noreferrer">http://www.howtocreate.co.uk/tutorials/javascript/browserwindow</a><br>
  which contains this piece of the puzzle, figuring out how big the browser window is:  </p>
  
  <pre><code>function alertSize() {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
    } else if( document.documentElement &amp;&amp; ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else if( document.body &amp;&amp; ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
    window.alert( 'Width = ' + myWidth );
    window.alert( 'Height = ' + myHeight );
  }
  </code></pre>