Code Comments
Programming Forum and web based access to our favorite programming groups.How can I determine the screen resolution of the user who is viewing my website? I want to use this do show a different background image and to hide some elements when the resolution is less than 1024 * 768. Wouter
Post Follow-up to this messageWouter wrote: > How can I determine the screen resolution of the user who is viewing my > website? > I want to use this do show a different background image and to hide some > elements when the resolution is less than 1024 * 768. > I assume you mean browser window size? Which is unrelated to screen resolution. Not with PHP directly. You can probably do it with Javascript (unreliably) and then send the values back in a new request. -- Oli
Post Follow-up to this messageOn Mon, 18 Apr 2005 19:33:20 +0200, Wouter wrote: > How can I determine the screen resolution of the user who is viewing my > website? > I want to use this do show a different background image and to hide some > elements when the resolution is less than 1024 * 768. > > Wouter You can do this with Javascript, but then you need to worry about whether the user has Javascript enabled, and then the whole cross browser issue (different browsers may use different commands and variables to get the screen width). With IE, I get the screen width only when my user logs on to my application (I assume the screen width won't change during a session) with document.form1.screenwidth.value = screen.width; where here I have a form named form1, and a hidden variable named screenwidth. On the server side I get the screenwidth from the $_POST array and save it in the session array after the user successfully logs in: $_SESSION['screenwidth'] = trim($_POST['screenwidth']) and then I use this on whatever pages need to be dependent on the screen width. Of course you need to check that the value is reasonable, as not all browsers will understand what you use to determine screen width, and you need to handle cases where the user disables javascript. In my case, all my navigation is performed using Javascript. If javascript is disabled, my audience doesn't get anywhere anyway.
Post Follow-up to this messageWouter wrote: > How can I determine the screen resolution of the user who is viewing my > website? > I want to use this do show a different background image and to hide some > elements when the resolution is less than 1024 * 768. > I assume you mean browser window size? Which is unrelated to screen resolution. Not with PHP directly. You can probably do it with Javascript (unreliably) and then send the values back in a new request. -- Oli
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.