Get browser information from HTTP_USER_AGENT..
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>
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 )
Remember, it sounds like "Netscape", but it's spelled like "Mozilla". Put this line in a DTML method/doc and see what it tells you. <dtml-var HTTP_USER_AGENT> Konqueror: Mozilla/5.0 (compatible; Konqueror/2.1 Beta 2; X11) Netscape: Mozilla/4.76 [en] (X11; U; Linux 2.4.1-1 i686) -Paul Pattreeya Tanisaro wrote:
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-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
-- Paul Erickson | erickson@kaivo.com Kaivo, Inc. | www.kaivo.com
participants (3)
-
Pattreeya Tanisaro -
Paul Erickson -
Tino Wildenhain