Инструменты пользователя

Инструменты сайта


programming:js:hints

Ништяки

function  GetSizes(){
    var w=document.documentElement; var d=document.body;
    var tww = document.compatMode=='CSS1Compat' && !window.opera?w.clientWidth:d.clientWidth;
    var twh = document.compatMode=='CSS1Compat' && !window.opera?w.clientHeight:d.clientHeight;
    var sl = (window.scrollX)?window.scrollX:(w.scrollLeft)?w.scrollLeft:d.scrollLeft;
    var st = (window.scrollY)?window.scrollY:(w.scrollTop)?w.scrollTop:d.scrollTop;
    var wW1 = (window.innerHeight && window.scrollMaxY)?d.scrollWidth:(d.scrollHeight > d.offsetHeight)?d.scrollWidth:(w && w.scrollHeight > w.offsetHeight)?w.scrollWidth:d.offsetWidth;
    var wH1 = (window.innerHeight && window.scrollMaxY)?d.scrollHeight:(d.scrollHeight > d.offsetHeight)?d.scrollHeight:(w && w.scrollHeight > w.offsetHeight)?w.scrollHeight:d.offsetHeight;
    var wW2 = (self.innerHeight)?self.innerWidth:(w && w.clientHeight)?w.clientWidth:d.clientWidth; var pW = (wW1 < wW2)?wW2:wW1;
    var wH2 = (self.innerHeight)?self.innerHeight:(w && w.clientHeight)?w.clientHeight:d.clientHeight; var pH = (wH1 < wH2)?wH2:wH1;
    pW = ($.browser.msie)?pW:Math.max(w.scrollWidth, w.clientWidth, d.scrollWidth, d.offsetWidth);
    pH = ($.browser.msie)?pH:Math.max(w.scrollHeight, w.clientHeight, d.scrollHeight, d.offsetHeight);
    if (window.opera){ tww = (d.scrollWidth==d.clientWidth)?w.clientWidth:tww; twh = (d.scrollHeight==d.clientHeight)?w.clientHeight:twh;}
    return {
        winWidth:tww,
        winHeight: twh,
        winScrollLeft: sl,
        winScrollTop: st,
        pageWidth: pW,
        pageHeight: pH
    }
}

function getScrollBarWidth () {
    var inner = document.createElement('p');
    inner.style.width = '100%';
    inner.style.height = '200px';
 
    var outer = document.createElement('div');
    outer.style.position = 'absolute';
    outer.style.top = '0px';
    outer.style.left = '0px';
    outer.style.visibility = 'hidden';
    outer.style.width = '200px';
    outer.style.height = '150px';
    outer.style.overflow = 'hidden';
    outer.appendChild (inner);
 
    document.body.appendChild (outer);
    var w1 = inner.offsetWidth;
    outer.style.overflow = 'scroll';
    var w2 = inner.offsetWidth;
    if (w1 == w2)
        w2 = outer.clientWidth;
    document.body.removeChild (outer);
 
    return (w1 - w2);
};
programming/js/hints.txt · Последнее изменение: 2017/03/27 11:28 — artur

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki