PDA

View Full Version : Linking to Stylesheet Code Help


D444NYC
02-12-2009, 01: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

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

Rob_Che
02-12-2009, 12:15 PM
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 ? :)

domedia
02-12-2009, 05: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". ;)

edbr
02-13-2009, 12:23 AM
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
<HEAD>
<?
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();

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;
document.cookie=the_cookie

location = 'get_resolution.php';
}
//-->
</script>
<?
}
?>
</HEAD>
<BODY>
<?php
echo "Your Screen resolution is set at ". $screen_res;
?>
</BODY>
</HTML>

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

Also:
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.

Rob_Che
02-16-2009, 02: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....