Test for browser version using dtml-if?
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? Michael
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
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 )
-- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ================================================================== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================
Hi AM, --On Mittwoch, 2. Oktober 2002 18:20 -0700 AM <list_subscriber@neurobs.com> 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'
Very clever ;) Whats with Opera, Lynx, Links, Mozilla, Konqueror, Amaya, Nokia6310, ... ? :-)
hth AM
Tino Wildenhain wrote:
Hi AM,
--On Mittwoch, 2. Oktober 2002 18:20 -0700 AM <list_subscriber@neurobs.com> 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'
Very clever ;) Whats with Opera, Lynx, Links, Mozilla, Konqueror, Amaya, Nokia6310, ... ? :-)
Even worse: What about the difference between NS4 on the one hand and NS6 and NS7 on the other hand? MFvM
As I said a simple one. I dont need more than that... Of course in the case of Opera... well if the user sets it to send out an IE or NS string so be it. -AM Tino Wildenhain wrote:
Hi AM,
--On Mittwoch, 2. Oktober 2002 18:20 -0700 AM <list_subscriber@neurobs.com> 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'
Very clever ;) Whats with Opera, Lynx, Links, Mozilla, Konqueror, Amaya, Nokia6310, ... ? :-)
hth AM
-- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ================================================================== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================
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 )
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.
<dtml-elif "_.string.find(HTTP_USER_AGENT, 'Konqueror') >0">
Thanks again,
Michael
Hi Michael, all the browser sends to the server you will find in the REQUEST object. If we speak DTML here (death to DTML anyway!), you would make yourself a picture with <dtml-var REQUEST> (IIRC) If you look at the resulting page, you migt find something like REQUEST.HTTP_USER_AGENT to look at. All whats left is up to your needs - see any standard python manual for substring search or pattern matching. Ooops. Forget about the pattern matching, this is disabled for DTML and stuff. Whatever you do, keep in mind: you never know whats really the browser. Most browsers will fake the version string. If you want to make something like "You dont have the right browser to look at our bloated webpages, go away and load down ..." Then I come and bash you personally ;) If you like to make a browser specific help, say to explain a user how to configure language settings for the specific Browser, detecting the Browser version to present matching screenshots is recommended. Regards Tino --On Mittwoch, 2. Oktober 2002 15:19 -0600 Michael <michael@exasource.com> 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?
Michael
_______________________________________________ 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 )
participants (6)
-
AM -
Michael -
Michael -
Michael Fischer v. Mollard -
Tim Hicks -
Tino Wildenhain