HOME       >>       Programming

Php Resolution Detection? Is it possible to do without using JS?


gaea

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.


electron

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.


rvalkass

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.


gaea

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.


VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.