| 
	
 | 
 Posted by Jeff North on 10/17/06 00:39 
On Mon, 16 Oct 2006 23:50:50 +0100, in comp.lang.php Steve Wright 
<usenet@wrightnet.demon.co.uk> 
<4RLhsRJKzANFFwgU@wrightnet.demon.co.uk> wrote: 
 
>| Hi 
>|  
>| I'm developing a webpage that needs to include a different stylesheet  
>| depending on the screen resolution. 
>|  
>| I know that I could read the resolution in javascript and then do some  
>| sort of stylesheet switcher as part of the onload event but I would  
>| rather link in the correct stylesheet for the resolution in the first  
>| place. 
>|  
>| Is there anyway of reading the screen resolution using PHP? 
 
Not really. 
 
>| Please don't flame me about "screen resolution being useless as not  
>| everyone browses in a maximised window". This is for intranet  
>| application where I know the browser will be IE6 with javascript enabled  
>| running in full screen mode and toolbars hidden. I also know the three  
>| possible screen resolutions that it could be. 
 
Let the browser do the work (like it should) and let the user select 
what option that they want. 
------------------------------------------------------------------- 
<head> 
<link rel="stylesheet" type="text/css" href="small.css" title="small" 
/> 
<link rel="alternate stylesheet" type="text/css" href="medium.css" 
title="medium" /> 
<link rel="alternate stylesheet" type="text/css" href="large.css" 
title="large" /> 
 
<script type="text/javascript"> 
function setActiveStyleSheet(title) 
{ 
  var i, a, main; 
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { 
    if(a.getAttribute("rel").indexOf("style") != -1 && 
a.getAttribute("title")) { 
      a.disabled = true; 
      if(a.getAttribute("title") == title) a.disabled = false; 
    } 
  } 
} 
</head> 
<body> 
<p><strong>Screen Size</strong><br /> 
<select name="lbCSS" id="lbCSS" 
onchange="setActiveStyleSheet(this.value);"> 
  <option value="small">Small</option> 
  <option value="medium">Medium</option> 
  <option value="large">Large</option> 
</select> 
</body> 
---------------------------------------------------------------------- 
If you want the appropriate css to be loaded each time then store the 
value in a cookie and read/update this value. 
 
ALternatively, you could use CSS floating layout. This will allow the 
browser to automatically resize it's contents. You only need 1 CSS 
file to manage the myriad of screen resolutions that are available. 
--------------------------------------------------------------- 
jnorthau@yourpantsyahoo.com.au  : Remove your pants to reply 
---------------------------------------------------------------
 
  
Navigation:
[Reply to this message] 
 |