Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get at the clients' screen size ?

0 views
Skip to first unread message

Erik

unread,
Apr 5, 2004, 10:26:46 AM4/5/04
to
I want to write a Server Side PHP program that generates a HTML page
client side.
How would I get at the clients' screen size, before serving the
generated page ?
Would it be a two-step process: first let the client execute a piece
of JavaScript to generate Height and Width, and then send those values
to the PHP server (FORM, PUT) ?
Or can it be done in only one PHP program ?


frgr
Erik

Erik

unread,
Apr 5, 2004, 5:00:27 PM4/5/04
to
On Mon, 05 Apr 2004 14:57:55 GMT, the right honourable "Ian.H"
<i...@WINDOZEdigiserv.net> wrote:

>On Mon, 05 Apr 2004 16:26:46 +0200, Erik wrote:
>
>> I want to write a Server Side PHP program that generates a HTML page
>> client side.
>
>

>OK...


>
>
>> How would I get at the clients' screen size, before serving the
>> generated page ?
>
>

>Wow! Umm.. silly question.. why on earth would you want to do this!?


To determin the exact layout, to determin the screen real estate
available to me to build the page....
Pages for a 640 screen would be different from a 1280 screen...


>
>
>> Would it be a two-step process: first let the client execute a piece
>> of JavaScript to generate Height and Width, and then send those values
>> to the PHP server (FORM, PUT) ?
>
>

>If you _really_ want to do this.. yes.


>
>
>> Or can it be done in only one PHP program ?
>
>

>No. As you stated in your first sentence, PHP is server-side and knows
>nothing of the client's environment.
>
>_IMO_ this is a complete waste of time, effort and resources.
>
>What about if I visit? or Lynx users? neither would run any Javascript you
>add thus defeating your idea before it's off the ground =)
>

still: would be nice to have a few client parameters, before building
the page...
Seems I am stuck with the least common denominator... a 640x480 or
something like that screen.... or build by ratios...

>
>
>Regards,
>
> Ian

Garp

unread,
Apr 5, 2004, 6:46:03 PM4/5/04
to

"Erik" <et57 at correos calor dot com> wrote in message
news:hlh370dl8i5f6i80c...@4ax.com...

> On Mon, 05 Apr 2004 14:57:55 GMT, the right honourable "Ian.H"
> <i...@WINDOZEdigiserv.net> wrote:
<snip>

> >Wow! Umm.. silly question.. why on earth would you want to do this!?
>
>
> To determin the exact layout, to determin the screen real estate
> available to me to build the page....
> Pages for a 640 screen would be different from a 1280 screen...
>
<snip>

Well, ugh. Make a layout that assumes nothing about the client and you won't
have to. Like most technical problems, this one stems from unwise design
choices. When the user resizes his browser window to look at something else
at the same time, are you going to regenerate the page for him?

Garp


Hayden Kirk

unread,
Apr 5, 2004, 7:47:34 PM4/5/04
to
More than 50% of peoples resolution are 1024/768 soo... You don;t need to
worry. Less than 10% is more than that, the rest is really 800x600.

- Hayden

"Erik" <et57 at correos calor dot com> wrote in message

news:94r270hbvs6l0dptg...@4ax.com...

Pedro Graca

unread,
Apr 5, 2004, 7:57:18 PM4/5/04
to
Hayden Kirk wrote:
> More than 50% of peoples resolution are 1024/768 soo... You don;t need to
> worry. Less than 10% is more than that, the rest is really 800x600.

My User-Agent string is:
ELinks/0.9.1 (textmode; Linux 2.6.4-1-386 i686; 108x46)

Yes, I know I'm one of the very few people in the whole wide world
who are completely shut out of a rapidly growing list of sites.

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :

Chung Leong

unread,
Apr 5, 2004, 11:04:01 PM4/5/04
to
"Erik" <et57 at correos calor dot com> wrote in message
news:94r270hbvs6l0dptg...@4ax.com...
> I want to write a Server Side PHP program that generates a HTML page
> client side.
> How would I get at the clients' screen size, before serving the
> generated page ?

You can't. Currently there's no mechanism for client capability discovery in
HTTP.

> Would it be a two-step process: first let the client execute a piece
> of JavaScript to generate Height and Width, and then send those values
> to the PHP server (FORM, PUT) ?

That's probably the only way. What you would do is assume the smaller size,
then redirect to the same page with the dimension added to the URL when more
space is available. Don't use the screen size though, as you can't assume
that the user will have the browser window maximized. Use the dimension of
the browser client area instead:

var h = document.body.clientWidth;
var w = document.body.clientHeight;

if(h > 800 && w > 600) {
location.replace(location.href + '?height=' + w + '&width=' + h);
}

A more ideal solution would dynamically link in a CSS style-sheet for the
larger available area.


Sandman

unread,
Apr 6, 2004, 8:43:02 AM4/6/04
to
In article <94r270hbvs6l0dptg...@4ax.com>,

Yes, run a page that has a javascript that just loads your php page if the
variables for the screens size exist, or have the user choose from a list of
predefined resolutions.

--
Sandman[.net]

Brandon Blackmoor

unread,
Apr 6, 2004, 6:13:18 PM4/6/04
to
Erik wrote:
>
> To determin the exact layout, to determin the screen
> real estate available to me to build the page...

Hey Erik: 1995 called, and they want their broken web design techniques
back.

Do yourself and anyone who look at your web site a favor, and read up on
the web standards, most of which date from the late 1990s (this, of
course, is 2004): http://webstandards.org/

bblackmoor
2004-04-06

John Dunlop

unread,
Apr 7, 2004, 3:43:33 AM4/7/04
to
Pedro Graca wrote:

> Hayden Kirk wrote:
>
> > More than 50% of peoples resolution are 1024/768 soo... You don;t
> > need to worry.

I start worrying when my website gets crippled by incompetent, soi-
disant designers too enamoured with their treasured gimcracks to care
about end-users.

> > Less than 10% is more than that, the rest is really 800x600.

Really? Hasn't anyone told you that 97 % of statistics are made up?

As to webpage authoring, screen dimensions are irrelevant; browser
window dimensions are irrelevant; canvas dimensions are irrelevant.
If you disagree with any of that, would you say that my system's
volume is relevant? If not, why not?

> My User-Agent string is:
> ELinks/0.9.1 (textmode; Linux 2.6.4-1-386 i686; 108x46)

That's informative.

Unfortunately, ignorant designers being two a penny now, user-agents
have taken to working against the intention of RFC2616. As I'm sure
you'll know already, Pedro, the User-Agent header "contains
information about the user agent originating the request" (RFC2616,
sec. 14.43); it isn't supposed to contain information about other
user-agents; it definitely isn't supposed to contain misinformation.
But it's almost standard practice nowadays for browsers to identify
themselves as one another, and to give users a choice of user-agent
strings. One of my screenreaders identifies itself as Mozilla/4.0!

> Yes, I know I'm one of the very few people in the whole wide world
> who are completely shut out of a rapidly growing list of sites.

If by "very few" you mean "many" (or "relatively few"), then I
suppose I must agree. :-) One might understandably be surprised at
how easy it is to be excluded from websites rigged up by designers
who are long on complacency and short on sound advice.

http://www.google.com/search?q=%22your%20browser%20doesn%20%22

--
Jock

Geoff Berrow

unread,
Apr 7, 2004, 6:25:55 AM4/7/04
to
I noticed that Message-ID:
<MPG.1addc184c...@News.Individual.NET> from John Dunlop
contained the following:

>If by "very few" you mean "many" (or "relatively few"), then I
>suppose I must agree. :-) One might understandably be surprised at
>how easy it is to be excluded from websites rigged up by designers
>who are long on complacency and short on sound advice.
>
> http://www.google.com/search?q=%22your%20browser%20doesn%20%22

The picture doesn't look quite so bad if you exclude frames
http://www.google.com/search?q=%22your+browser+doesn%22-frames

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Garp

unread,
Apr 8, 2004, 12:16:21 PM4/8/04
to

"Erik" <et57 at correos calor dot com> wrote in message
news:94r270hbvs6l0dptg...@4ax.com...

First, yes, but second, don't do it:
http://groups.google.com/groups?q=%22how+to+get+at+the+clients%27%22+php&hl=en&lr=&ie=UTF-8&selm=94r270hbvs6l0dptg191iqlq8dgk9o6ga2%404ax.com&rnum=1

Moral is, don't design your pages around the dimensions of the window that
called the page up. Just make it fit 800x600 if you have to assume a size (>
80% users), but better yet, make it fit ANY size with relative sizing. The
user can always scroll sideways (unless they use WebTV, but hey).

Garp


0 new messages