[thelist] Browser Detect with JavaScript

Michael Collins mcollins206 at home.com
Sun Dec 3 10:08:26 CST 2000


>  > thanks for the reminder. So basically if a Web browser can pass the
>>  test of understanding the w3c DOM or at least the IE4 "all" version
>>  of the DOM then I can consider that browser will be capable of
>>  displaying my CSS1 site with perhaps only a few problems.
>
>Well sort of ie3 has css1 support.
>What the script does is check whether is document is scriptable by using the
>various 'dom' objects made available with browsers versions .

So in other words it isn't really all that practical for public Web 
sites where you want to allow access to 90% of users? Unless you have 
a defined list of browsers for a specific audience and are requiring 
browsers that support the DOM. Thus I have to go back to my original 
idea of checking for browsers types and version numbers?

Or I can combine what you are saying to broaden the browsers allowed in using:

function brwcheck() {

    // The default is set to false (incompatible),
   var resultck=false; 

    // Then all compatible browsers are set to true
    // DOM1 compliance ns6 and IE5 and opera 4+
   if(document.getElementsByTagName){resultck=true;}

    // IE4 all DOM
   if (document.all){resultck=true;}

    // Disallow IE 3
     var agt=navigator.userAgent.toLowerCase();
   var is_ie=(agt.indexOf("msie") !=-1);
   if(is_ie==true) { var 
is_minor=parseFloat(agt.substring(agt.indexOf('msie')+4,(agt.indexOf('msie')+11)));}
   if(is_ie==true && is_minor<4) {resultck=false;}

   if(resultck==false){
     document.write('You Web browser sucks!');
   }
}

I am not checking for document.layers and document.images since I 
don't want to consider these implementations compatible:

However if I want to allow just the latest versions of Netscape 4 I 
could work in:

var is_nav=((agt.indexOf("mozilla")!=-1) && 
(agt.indexOf("spoofer")==-1) && (agt.indexOf("compatible")==-1));
var is_minor=parseFloat(navigator.appVersion);
if((is_nav==true)&&((is_minor>=4.7) || (is_minor==4.08))){resultck=true;}


Michael
-- 
==> Michael Collins
--> Kuwago Web Services
--> Seattle, WA, USA
--> mcollins at nwlink.com
==> http://www.lassodev.com




More information about the thelist mailing list