Jump to content
xisto Community
gaea

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

Recommended Posts

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

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.