window width and height

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bern

    window width and height

    how to get the width and height of the visible window in IE, netscape and
    mozilla?


  • Andrew Thompson

    #2
    Re: window width and height

    On Fri, 15 Oct 2004 21:01:41 +0800, Bern wrote:
    [color=blue]
    > how to get the width and height of the visible window in IE, netscape and
    > mozilla?[/color]

    <script type='text/javascript'>
    var viewWidth;
    var viewHeight;

    function determineViewab leSize() {
    d=document;
    if (typeof window.innerWid th!='undefined' ) {
    viewWidth = window.innerWid th;
    viewHeight = window.innerHei ght;
    } else {
    if (d.documentElem ent &&
    typeof d.documentEleme nt.clientWidth! ='undefined' &&
    d.documentEleme nt.clientWidth! =0) {
    viewWidth = d.documentEleme nt.clientWidth
    viewHeight = d.documentEleme nt.clientHeight
    } else {
    if (d.body &&
    typeof d.body.clientWi dth!='undefined ') {
    viewWidth = d.body.clientWi dth
    viewHeight = d.body.clientHe ight
    }
    }
    }
    }

    function getViewableWidt h() {
    if (!viewWidth) determineViewab leSize();
    return viewWidth;
    }

    function getViewableHeig ht() {
    if (!viewHeight) determineViewab leSize();
    return viewHeight;
    }

    function viewableSize() {
    return "<b>Viewabl e</b> size: " +
    getViewableWidt h() + "x" + getViewableHeig ht() + ".";
    }
    </script>

    HTH

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.lensescapes.com/ Images that escape the mundane

    Comment

    Working...