| 
 Posted by Chung Leong on 10/17/06 05:45 
Steve Wright 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? 
 
Nope. The use of document.write (circa 1990s) will work just as well 
though. 
 
<script> 
 
var css = 'norm.css'; 
 
if(screen.availHeight > 1024) { 
  css = 'big.css'; 
} 
/* ...  etc. ... */ 
 
document.write('<link rel="stylesheet" type="text/css" href="' + css + 
'">'); 
 
</script>
 
  
Navigation:
[Reply to this message] 
 |