SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2003
    Location
    Miami
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    browser display size

    Hi All, I don't know if this is possible.
    I'm trying to figure out how to detect the client's browser display size. I know how to detect the client's screen size but I don't want that. If the client doesn't have its browser screen maximize I want to know the current browser display size

    Thanks In advance..

    Carlos

  2. #2
    SitePoint Member
    Join Date
    Nov 2003
    Location
    Miami
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I forgot something;

    someone told me to use screen.availwidth and screen.availheight, but I think that doesn't work in IE. I tried it and it gives me the screen size not the browser display size.

  3. #3
    SitePoint Zealot johno's Avatar
    Join Date
    Sep 2003
    Location
    Bratislava, Slovakia
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using this one pretty long.

    Code:
    function getBrowserWidth() { return document.getElementsByTagName("html")[0].offsetWidth; }
    function getBrowserHeight() { return document.getElementsByTagName("html")[0].offsetHeight; }
    Annotations support for PHP5
    TC/OPT™ Group Leader

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's another suggestion (from the X library):
    Code:
    function xClientWidth() {
      var w=0;
      if(xOp5or6) w=window.innerWidth;
      else if(!window.opera && document.documentElement && document.documentElement.clientWidth)
        w=document.documentElement.clientWidth;
      else if(document.body && document.body.clientWidth)
        w=document.body.clientWidth;
      else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
        w=window.innerWidth;
        if(document.height>window.innerHeight) w-=16;
      }
      return w;
    }
    function xClientHeight() {
      var h=0;
      if(xOp5or6) h=window.innerHeight;
      else if(!window.opera && document.documentElement && document.documentElement.clientHeight)
        h=document.documentElement.clientHeight;
      else if(document.body && document.body.clientHeight)
        h=document.body.clientHeight;
      else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
        h=window.innerHeight;
        if(document.width>window.innerWidth) h-=16;
      }
      return h;
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •