[Javascript] Browser sniffing!

Paul Novitski paul at juniperwebcraft.com
Wed Jan 10 18:12:59 CST 2007


At 1/10/2007 03:51 AM, Information - Abyss wrote:
>I am wanting to write a Javacript file that will find a browsers 
>name and browser version
>
>so that anything less then IE 7 it displays an error message
...


The main problem with browser-sniffing with javascript is that it 
assumes, erroneously, that HTTP_USER_AGENT always correctly reports 
the browser name and version.  It doesn't.

I don't know if this falls within the scope of what you're trying to 
achieve, but instead of javascript you could simply use Microsoft's 
conditional comments.  They have the advantage of being executed -- 
accurately and only -- by Internet Explorer:

<!--[if lt IE 7]>
         <script type="text/javascript">
                 alert('Not IE 7');
         </script>
<![endif]-->

http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp
http://www.quirksmode.org/css/condcom.html

Regards,
Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com




More information about the Javascript mailing list