View Full Version : Linking to Stylesheet Code Help

02-12-2009, 12:22 AM
Hey there everybody!

I need some help here, i'm currently created a website for a family business and everything is nearly completed and working mainly on it with my laptop which is fine and looks great but as soon as i try it on my computer, it moves around. I've got it sorted out for different browsers so that it will work with firefox, explorer etc but its when it comes to work with different screen resolutions and different browsers in one section of code.

I'm not very good when it comes to doing code like this so all the help would be great.

So, in short - I need some code that detect the browser and screen resoultion and then get the correct stylesheet.

Thanks, Dan

02-12-2009, 04:42 AM
$_SERVER["HTTP_USER_AGENT"]; will give browser info

02-12-2009, 11:15 AM
Ed, I think D444NYC means code that will 'call' the correct style sheet depending on the browser, but I may be wrong... (it has been known)

We've been here before haven't we ? :)

02-12-2009, 04:08 PM
Dan, you have to give a link or something so we know what you're talking about. Without it, all I can say is: "You're doing something wrong". ;)

02-12-2009, 11:23 PM
your are right rob of course
should have read it better. i just yahoogled and as far as i can see it would need javascript to get screen res. usually this is then set as cookies so it would need a screen refresh.
wouldn't a fluid layout be a consideration D444NYC?

BTW this was some code i fond donated
$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
<script language="javascript">

function writeCookie()
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;

location = 'get_resolution.php';
echo "Your Screen resolution is set at ". $screen_res;

02-13-2009, 01:01 AM
Sounds like the whole approach is wrong..
Wouldn't it be better to create a design that work independently from size?

It is not the Screen Resolution that makes the site break.
It is the Browser Size that makes the site break.

Browser size is not the same as screen resolution. Studies show that the larger the monitor size, the larger the difference between screen res and browser size is. So even using JS to find screen resolution does not stop the page from breaking.

02-16-2009, 01:33 PM
That's interesting DoMedia . . .

But as you say, and Ed touched on, I think a better layout is required. A layout that either 'works' in different resolutions or adapts to fit....