gaea 0 Report post Posted September 9, 2006 A quick question for all you coders. I'm looking for a way to autodetect a viewer's screen resolution without using javascript (as some people have it disabled). Is there any way to do this via a purely server side function, e.g. php? Thanks. Share this post Link to post Share on other sites
electron 0 Report post Posted September 9, 2006 Well till where i know this is impossible.Also if the user has no javascript request them to switch it on.But why do you need PHP to do this work because it is Server side while Javascript is Client side. Share this post Link to post Share on other sites
rvalkass 5 Report post Posted September 9, 2006 It is impossible for PHP to detect the size of the browser window. PHP is run on the web server and outputs the results of the functions you tell it to run as HTML code, no PHP ever reaches the client browser. You will need a client-side scripting language, one run on the viewer's browser, so that it can detect what is happening on their PC. All client side scripts can be disabled though, so you won't avoid that problem.Why do you need to detect the browser size anyway? If it's for a layout surely you can use some CSS tricks to achieve the same? It may not look that pretty but people can't disable it and they very rarely read through your CSS. Share this post Link to post Share on other sites
gaea 0 Report post Posted September 9, 2006 It is impossible for PHP to detect the size of the browser window. PHP is run on the web server and outputs the results of the functions you tell it to run as HTML code, no PHP ever reaches the client browser. You will need a client-side scripting language, one run on the viewer's browser, so that it can detect what is happening on their PC. All client side scripts can be disabled though, so you won't avoid that problem.Why do you need to detect the browser size anyway? If it's for a layout surely you can use some CSS tricks to achieve the same? It may not look that pretty but people can't disable it and they very rarely read through your CSS. I didn't think there was a way, but I figured I mind as well ask. As for the use, yes it is for a layout. I'll probably wind up writting a javascript to switch the stylesheets. And have a no script default. Share this post Link to post Share on other sites