Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Screen resolution
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




Report this thread to moderator Post Follow-up to this message
Old Post
Wouter
04-18-05 08:56 PM


Re: Screen resolution
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.
>

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

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
04-18-05 08:56 PM


Re: Screen resolution
On 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.


Report this thread to moderator Post Follow-up to this message
Old Post
coolsti
04-19-05 01:55 PM


Re: Screen resolution
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.
>

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

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
04-21-05 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.