Tom, Try this (only slightly tested) <dtml-call "REQUEST.set('ua',HTTP_USER_AGENT)"> <dtml-if "_.string.find(ua,'MSIE') != -1"> <dtml-comment> Its MSIE </dtml-comment> <dtml-call "REQUEST.set('bMSIE',1)"> <dtml-if "_.string.find(ua,'MSIE 3.0') != -1"> <dtml-call "REQUEST.set('bMSIE3',1)"> </dtml-if> <dtml-call "REQUEST.set('iMSIE4',_.string.find(ua,'MSIE 4.0'))"> <dtml-if "iMSIE4 == -1"> <dtml-call "REQUEST.set('iMSIE4',_.None)"> </dtml-if> <dtml-if iMSIE4> <dtml-call "REQUEST.set('bMSIE4',1)"> </dtml-if> <dtml-if bMSIE4> <dtml-call "REQUEST.set('minorVer',ua[iMSIE4+8])"> <dtml-if bMSIE4> <dtml-if "minorVer == 'p' or minorVer == 'b'"> <dtml-call "REQUEST.set('bMSIE4_beta',1)"> </dtml-if> <dtml-if "minorVer == '1'"> <dtml-call "REQUEST.set('bMSIE4_01',1)"> </dtml-if> </dtml-if> </dtml-if> <dtml-if "_.string.find(ua,'MSIE 5') != -1"> <dtml-call "REQUEST.set('bMSIE5',1)"> </dtml-if> <dtml-else> <dtml-comment> Let's assume netscape </dtml-comment> <dtml-call "REQUEST.set('bNetscape',1)"> <dtml-if "ua[8] >= '4'"> <dtml-call "REQUEST.set('bNetscape_4',1)"> <dtml-elif "ua[8] >= '3'"> <dtml-call "REQUEST.set('bNetscape_3',1)"> <dtml-else> <dtml-call "REQUEST.set('bNetscape_2',1)"> </dtml-if> </dtml-if> Include this in your standard_html_header and then use the variables in your pages as normal,so: <dtml-if bNetscape_4> do netscape specific stuff <dtml-elif bMSIE4_01> do IE specific stuff </dtml-if> HTH Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Tom Scheidt" <tom@falsemirror.com> To: <zope@zope.org> Sent: 16 March 2000 18:36 Subject: [Zope] Browser Detection
Is there a way to write a <dtml-if> for browser detection, like:
<dtml-if (User Agent is Netscape 4.5)> Use this <dtml-elif (User Agent is Internet Explorer 5.0)> Use this </dtml-if>
Thanks in advance.
************************* Tom Scheidt www.falsemirror.com tom@falsemirror.com *************************
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )