[thelist] the regular expression for detecting gecko browser later then Fx 1.0?

Zhang Weiwu zhangweiwu at realss.com
Fri Apr 28 03:56:47 CDT 2006

The application I am working on detects the current browser and, if certain
browser is not tested, give a warning message.

Currently tested browser is Firefox 1.0+ and IE 5.5+. But later I get
complaint because some users are using K-meleon and works fine, and they get
the warning message. Thus I realize I should not detect browser USER_AGENT
against Firefox, rather intead, I should detecte the gecko layout engin, if
the layout engin is later then the one used on Firefox 1.0, the system
should work without warning.

Thus I changed detection script to this (in php but easy to understand)

	if (ereg('Gecko\/([[:digit:]]+)', $_SERVER['HTTP_USER_AGENT'],
	$regs) && $regs[1] >= '20041124') /* if compatible */

Immediately I got complaint from another Debian user who also get warning
message because this is his USER AGENT:

 Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/Debian-1.5.dfsg+ Firefox/

So is there an universal way to detect if the gecko browser is supported? I
could for sure add some test like ereg('Gecko\/Debian-1') for debian, but
what if someone come up ask their firefox on yellowdog Linux, firefox on xxx
OS gives fault warning message?

Any suggestions?

Reference: gecko user-agent string

Zhang Weiwu   Real Softservice
International business: http://www.realss.com
International sales:    0086 10 84606011
Inland business:        http://www.realss.cn
Inland sales call:      0086 592 2099987
                Sent from Pine: http://www.washington.edu/pine/

More information about the thelist mailing list