Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. I can't get window.innerHeight on IE7. How to fix?
  2. $(window).height();
  3.        
  4. jQuery.getScrollBarSize = function() {
  5.    var inner = $('<p></p>').css({
  6.       'width':'100%',
  7.       'height':'100%'
  8.    });
  9.    var outer = $('<div></div>').css({
  10.       'position':'absolute',
  11.       'width':'100px',
  12.       'height':'100px',
  13.       'top':'0',
  14.       'left':'0',
  15.       'visibility':'hidden',
  16.       'overflow':'hidden'
  17.    }).append(inner);
  18.  
  19.    $(document.body).append(outer);
  20.  
  21.    var w1 = inner.width(), h1 = inner.height();
  22.    outer.css('overflow','scroll');
  23.    var w2 = inner.width(), h2 = inner.height();
  24.    if (w1 == w2 && outer[0].clientWidth) {
  25.       w2 = outer[0].clientWidth;
  26.    }
  27.    if (h1 == h2 && outer[0].clientHeight) {
  28.       h2 = outer[0].clientHeight;
  29.    }
  30.  
  31.    outer.detach();
  32.  
  33.    return [(w1 - w2),(h1 - h2)];
  34. };