[Zope] Get browser information from HTTP_USER_AGENT..

Tino Wildenhain tino@wildenhain.de
Sat, 24 Feb 2001 00:06:42 +0100


Hi Pattreeya,

First of all, DONT USE USERAGENT header for anything but informal.
You simply cant depend on that because its free form. Much hassle
these days came from people who didnt understand that. Thats why all
browsers call themself "Mozilla"...

Best way to get "informal" things from the browsers is a simple dtml-page:

<dtml-var REQUEST>

Try it with different User-Agents at will and you will see.
Always a goot thing [tm] would be a in depth knowledge of the
http-protocol as defined in rfc2616 (www.faqs.org)

HTH
Tino Wildenhain

> Hello!
> 	 I would like to get the information about user's browser but when I
> add these following tags in my dtml header, the result from the third
> condition is always true.  (I checked with netscape and konqueror and the
> results were the same, Your browser is neither IE nor Netscape. )
>
>	 Thank you so much in advance for any suggestion.
>
> <dtml-if "_.string.find(_['HTTP_USER_AGENT'], 'MSIE')  <> -1">
>     <link href="<dtml-var "msie_css.absolute_url()">" rel="stylesheet"
> type="text/css">
>	 Your browser is IE.
>     <dtml-elif "_.string.find(_['HTTP_USER_AGENT'], 'NETSCAPE') <> -1">
>     <link href="<dtml-var "netscape_css.absolute_url()">"
>     rel="stylesheet"  type="text/css">
>	 Your browser is Netscape.
>     <dtml-else>
>     <link href="<dtml-var "lw_global_css.absolute_url()">"
>     rel="stylesheet"  type="text/css">
>	 Your browser is neither IE nor netscape.
>     </dtml-if>
>
> _______________________________________________
> 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 )