Re: Help me about detect client screen resolution!!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 1/2/2007 12:24 AM, Le Phuoc Canh wrote:
Can we use php to detect client screen resolution? Please help me ?


Do you really want screen resolution or do you want browser window size? Not every PC user keeps their windows maximized, and I have yet to meet a Mac user who attempts to do so.

For cross-browser javascript that measures the viewport, see Peter-Paul Koch's page:

        Viewport properties
        http://www.quirksmode.org/viewport/compatibility.html

PHP and javascript can act in concert. If PHP doesn't yet know the monitor size, it can download a javascript-only page that will talk back, e.g.:

        document.location.href = '?width=' . x . '&height=' . y

which PHP can receive as $_GET['x'] and $_GET['y'] and then use to download the desired page.

Keep in mind that the user can change window size at any time and many people do so from one page to the next to accommodate varying content and their other desktop activities at the time. Therefore you can't really rely on intial measurements; if the proper rendering of your page DEPENDS on knowing the window size, you'll need to re-measure it for every pageview. Downloading a measuring script in advance of each web page would make the browsing experience a bit sluggish.

If possible, try to make your page layouts more robust. There are many techniques for engineering pages to tolerate a wide spectrum of window widths; see the CSS-D wiki for links:
http://css-discuss.incutio.com/

Regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux