[Zope] Different stylesheet for different browsers
fred@ontosys.com
fred@ontosys.com
Fri, 28 Jun 2002 14:07:26 -0500
On Thu, Jun 27, 2002 at 11:50:47PM -0700, Aseem Mohanty wrote:
> Just look at the HTTP-USERAGENT or somthing like that field in the
> REQUEST object...
> Thomas Weholt wrote:
> >How can I use one stylesheet for Netscape and older browsers and another for
> >Mozilla, IE, Opera etc ?
I use code like this at the beginning of a DTML Method that implements
my CSS file:
<dtml-call "RESPONSE.setHeader('Content-Type', 'text/css')">
<dtml-call "RESPONSE.setHeader('Last-Modified', bobobase_modification_time().toZone('GMT').rfc822())">
<dtml-call "RESPONSE.setHeader('Cache-Control','private, max-age=3600')">
<dtml-if "_.string.find(HTTP_USER_AGENT, 'MSIE') != -1">
<dtml-comment> Use smaller fonts for MSIE </dtml-comment>
OL,UL,P,BODY,TD,TR,TH,FORM,.default { font-size: x-small; }
.smaller, .footer { font-size: xx-small; }
<dtml-else>
OL,UL,P,BODY,TD,TR,TH,FORM,.default { font-size: small; }
.smaller, .footer { font-size: x-small; }
</dtml-if>
The fixed part of the CSS file follows that. The first three lines
are my quick&dirty hack to make the URL cacheable (done before Cache
Manager became available).
My code only calls out MSIE as a special case. You'd have to figure
out the HTTP_USER_AGENT values that apply to the cases you want to
discriminate.
--
Fred Yankowski fred@ontosys.com tel: +1.630.879.1312
OntoSys, Inc PGP keyID: 7B449345 fax: +1.630.879.1370
www.ontosys.com 38W242 Deerpath Rd, Batavia, IL 60510-9461, USA