View Full Version : How to determine screen res / width with PHP

03-14-2009, 04:47 PM
Is it possible, I'm sure it must be, to determine a users screen resolution or browser width using PHP.

I want to check this before a page is displayed so as to avoid horizontal scroll bars if the user has a low res screen or to advise that the website is best viewed at a higher res.

Regards, Paul

03-14-2009, 06:14 PM
cant do this with php but you can with javascript

Found this example...
var winW = 630, winH = 460;

if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
winW = window.innerWidth;
winH = window.innerHeight;
if (navigator.appName.indexOf("Microsoft")!=-1) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;

"Window width = "+winW+"<br>"
+"Window height = "+winH

remember you have to accomodate those that dont use javascript and the code has to fail gracefully