Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #10075

Re: Sizing on android phone

Newsgroups comp.lang.javascript
Subject Re: Sizing on android phone
From "Evertjan." <exjxw.hannivoort@interxnl.net>
References <N-idnTeX_otixZfSnZ2dnUVZ_rudnZ2d@westnet.com.au> <2320864.tvUHyB9DHY@PointedEars.de> <gPqdneL6M_JaR5fSnZ2dnUVZ_jGdnZ2d@westnet.com.au>
Message-ID <Xns9FD59C8E9578Beejj99@194.109.133.133> (permalink)
Date 2012-01-09 14:23 +0000

Show all headers | View raw


Andrew Poulos wrote on 09 jan 2012 in comp.lang.javascript:

> I call this function:
> 
> function getViewPort(win) {
>    win = win || window;
>    if (typeof win.document.clientWidth == "number") {
>      return [win.document.clientWidth, win.document.clientHeight];
>    } else if (win.document.documentElement &&
>               win.document.documentElement.clientHeight) {
>      return [win.document.documentElement.clientWidth,
>              win.document.documentElement.clientHeight];
>    } else {
>      return [win.document.body.clientWidth,
>              win.document.body.clientHeight];
>    }
>}
> 

The if...return works a bit like the infamous if...goto,
so the elses are superfluous.

==========

function getViewPort(win) {
  win = (win || window).document;
  var r = win.body;
  if (typeof win.clientWidth == "number") r = win;
  win = win.documentElement;
  if (win && win.clientHeight) r = win;
  return [r.clientWidth, r.clientHeight];
};

Just playing ;-)


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Sizing on android phone Andrew Poulos <ap_prog@hotmail.com> - 2012-01-09 14:03 +1100
  Re: Sizing on android phone "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-08 21:23 -0800
  Re: Sizing on android phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-09 12:15 +0100
    Re: Sizing on android phone Andrew Poulos <ap_prog@hotmail.com> - 2012-01-09 23:17 +1100
      Re: Sizing on android phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-09 14:02 +0100
        Re: Sizing on android phone "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-09 11:36 -0800
          Re: Sizing on android phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-09 22:10 +0100
        Re: Sizing on android phone Andrew Poulos <ap_prog@hotmail.com> - 2012-01-10 06:48 +1100
          Re: Sizing on android phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-09 22:15 +0100
            Re: Sizing on android phone Andrew Poulos <ap_prog@hotmail.com> - 2012-01-10 08:31 +1100
              Re: Sizing on android phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-09 23:45 +0100
      Re: Sizing on android phone "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-09 14:23 +0000
  Re: Sizing on android phone "J.R." <groups_jr-1@yahoo.com.br> - 2012-01-12 04:29 -0200
    Re: Sizing on android phone "J.R." <groups_jr-1@yahoo.com.br> - 2012-01-12 06:13 -0200
  Re: Sizing on android phone Arno Welzel <usenet@arnowelzel.de> - 2012-01-12 15:11 +0100
    Re: Sizing on android phone Andrew Poulos <ap_prog@hotmail.com> - 2012-01-13 11:30 +1100
      Re: Sizing on android phone Arno Welzel <usenet@arnowelzel.de> - 2012-01-13 14:52 +0100
  Re: Sizing on android phone Dan <dan@tobias.name> - 2012-01-12 10:11 -0800
    Re: Sizing on android phone Andrew Poulos <ap_prog@hotmail.com> - 2012-01-13 11:41 +1100

csiph-web