Forum Moderators: coopster

Message Too Old, No Replies

Resolution Detections

         

Tourex

9:24 am on Oct 14, 2005 (gmt 0)

10+ Year Member



I'm preparing a new site and need/want to detect the reader's browser resolution. The basic aim is that a different CSS definition will be used if the user's resolution is 800pixels or less.

I appreciate that the detection with have to be done with JavaScript (with which I have very little experience), but I'm trying to figure the best way for the JavaScript to pass the information to a PHP which will obviously write the <link href... CSS line.

Can anyone help please.

Also, at the same time, I would ideally like to do a cookie test and establish whether cookies are disabled on the user's machine. Again, my question is how to pass that information to PHP scripts?

Thanks in anticipation.

whoisgregg

11:17 pm on Oct 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Typically, javascript is used to write the appropriate <link /> element [webmasterworld.com]. Are there other considerations that require the screen resolution be passed to PHP?

Tourex

9:57 am on Oct 16, 2005 (gmt 0)

10+ Year Member



Hi

Thanks - I've found JavaScript that writes the link, so that side is fine, thanks.

I now have another 'problem'.

Our default layout (including JavaScript disabled) assumes that the user has a screen resolution greater than 800x600.

Within the page, a PHP script is called to populate the promotional sidebars (include ("...../sidebars.php").

If the user's screen width is determined to be 800 or less (screen.width <= 800) I want to set a variable allowing me to initiate a different version of sidbars.php (e.g. sidebar.php?LR=X ) that would populate the sidebars in a different (less dense) way.

Any thoughts anybody? Also, how do I force the page refresh that will obviously be necessary if we find that the screen is low resolution?

ergophobe

3:50 pm on Oct 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If they have JS disabled, you won't be able to detect resolution, plain and simple. What you might be able to do is

1. put a link "change screen resolution" on the big version

2. put a meta refresh inside <noscript> tags and redirect to a page that lets them choose a resolution.