By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,746 Members | 1,780 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,746 IT Pros & Developers. It's quick & easy.

How to get at the clients' screen size ?

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
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!?

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 =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2

P: n/a
On Mon, 05 Apr 2004 14:57:55 GMT, the right honourable "Ian.H"
<ia*@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


Jul 17 '05 #3

P: n/a

"Erik" <et57 at correos calor dot com> wrote in message
news:hl********************************@4ax.com...
On Mon, 05 Apr 2004 14:57:55 GMT, the right honourable "Ian.H"
<ia*@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
Jul 17 '05 #4

P: n/a
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:94********************************@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 ?
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

Jul 17 '05 #5

P: n/a
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 :
Jul 17 '05 #6

P: n/a
"Erik" <et57 at correos calor dot com> wrote in message
news:94********************************@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.
Jul 17 '05 #7

P: n/a
In article <94********************************@4ax.com>,
Erik <et57 at correos calor dot com> wrote:
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 ?


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]
Jul 17 '05 #8

P: n/a
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
Jul 17 '05 #9

P: n/a
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=%22yo...%20doesn%20%22

--
Jock
Jul 17 '05 #10

P: n/a
I noticed that Message-ID:
<MP************************@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=%22yo...%20doesn%20%22


The picture doesn't look quite so bad if you exclude frames
http://www.google.com/search?q=%22yo...oesn%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/
Jul 17 '05 #11

P: n/a
On Wed, 07 Apr 2004 08:43:33 +0100, John Dunlop wrote:

Unfortunately, ignorant designers being two a penny now

Typically windoze (l)users / deezyners and think that IE is the be all and
end all.

It must be horrible having tunnel vision.. blurry tunnel vision at that.

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #12

P: n/a

"Erik" <et57 at correos calor dot com> wrote in message
news:94********************************@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 ?
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


First, yes, but second, don't do it:
http://groups.google.com/groups?q=%2...4ax.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
Jul 17 '05 #13

P: n/a
On Thu, 08 Apr 2004 16:16:21 +0000, Garp wrote:
[ snip ]
The user can always scroll sideways (unless they use WebTV, but hey).

And this is another of the most infamous pet hates!

Avoid the horizontal scroll bars like the plague =)

Your "relative size" statement was much better.. make it fit "any" browser
size.

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.