[Zope] Test for browser version using dtml-if? Thanks

Michael michael@nichestaffing.com
Tue, 8 Oct 2002 15:58:50 -0600


Thanks AM and Tim.  Once I start converting all of the dtml scripts over to 
Python this will come in handy.  What I found was an old how-to from about a 
year and a half ago from jooi, that once modified, works fine on the fly.  In 
case there is anyone else interested in a dtml method of testing for browser 
types, here it is.

<dtml-if "_.string.find(HTTP_USER_AGENT, 'MSIE') >0">
Do something that works in Windows
<dtml-elif "HTTP_USER_AGENT[:9] >= ('Mozilla/4')">
Do something that works with Moz compatibles
<dtml-else>
Nothing works
</dtml-if>

Once I figure out how to filter out and test for Konqueror (in which nothing 
seems to work) from the Moz compatibles, I'll post that too.

Thanks again,

Michael



On Wednesday 02 October 2002 07:20 pm, AM wrote:
> Did you try using :
>
> REQUEST.HTTP_USER_AGENT
>
> I use a simple one like this:
>
> if container.REQUEST.HTTP_USER_AGENT.find('Netscape') > -1: return 'NS'
> else: return 'IE'
>
> hth
> AM
>
> Tim Hicks wrote:
> >>Does anyone know how to test for browser version using <dtml-if>?  I  can
> >
> >do
> >
> >>it with javascript, but was wondering if it is possible to just use an if
> >>statement?
> >
> >You might try http://www.zope.org/Members/svenasse/UserSniffer .  It
> > doesn't seem to have been updated in a while, but it worked quite nicely
> > when a used it before.
> >
> >hth,
> >
> >tim
> >
> >
> >_______________________________________________
> >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 )