Page 1 of 1

obtaining client resolution

Posted: Tue Mar 30, 2004 6:19 am
by davidklonski
Hi

I am trying to fit my page content based on the client resolution.
Is it possbile to retrieve that information in PHP? and if so how?

thanks in advance

Posted: Tue Mar 30, 2004 6:42 am
by John Cartwright
this is not server-side...

your thinking of a javascipt

Code: Select all

<SCRIPT LANGUAGE="Javascript">
if (screen.width < 800 && screen.height < 600) &#123;
     document.write("Site best viewed with a 800 by 600 resolution.");
&#125;
else &#123;
     document.write("Your current resolution is bigger than 800 by 600.");
&#125;
</SCRIPT>
Hope this helps

Posted: Tue Mar 30, 2004 7:02 am
by davidklonski
What can I do if I want to render content (in the server-side) based on the client resolution? For example, I if the resolution is high enough, I would like to display some content from the database. If the resolution is not high enough, don't display anything.

If I am at the client side, than it is too late and the page at already been rendered.

Isn't there a way to do it in PHP?

thanks

Posted: Tue Mar 30, 2004 7:23 am
by twigletmac
No there isn't a way to directly grab the resolution via PHP you have to use client-side scripting like Javascript.

Mac

Posted: Tue Mar 30, 2004 7:23 am
by magicrobotmonkey
You could simply build both possible pages with php and then let javascript decide between them

Posted: Tue Mar 30, 2004 11:36 am
by Unipus
use javascript to do stylesheet switching. in the low-res version of the stylesheet, have those database entried styled with display: none;

Posted: Tue Mar 30, 2004 11:36 am
by Unipus
of course, you'd better make it sure it degrades properly if javascript is turned off.

Posted: Tue Mar 30, 2004 11:53 am
by magicrobotmonkey
yea true make low-res the default

Posted: Tue Mar 30, 2004 12:06 pm
by twigletmac
Why not give the user a choice? They may have a high resolution but browse with the window quite small or they may have a low resolution but not mind scrolling sideways...

Mac

Posted: Tue Mar 30, 2004 12:50 pm
by Roja
Make an entry screen. Whether a login screen, or a quick redirect, have the entry screen detect their browser size.

Then, using http redirect, send them to the next page, with a variable set with the browser size.

Simple, effective, and gives PHP the knowledge of the client-side.

Ideally, if it can't detect it, it should default to low resolution.

Of course, the best idea would be to avoid locked-resolution designs at all costs. Consider people that need to increase their font sizes for accessibility, people that use palm devices, and so on..

If you design the site to be accessible, you wont need locked-resolutions. The obvious sidenote being that locked-resolutions are almost never accessible.