[thelist] Browser Detect with JavaScript
Grant
emerge at ps.gen.nz
Fri Dec 1 22:08:45 CST 2000
> OK, I am sure many of you have your own way and reasons for detecting
> browser type and version using JavaScript. There are plenty of
> references for existing scripts that are available but none do
> exactly what I want so I ma making my own. I wanted to share this
> script and ask if anyone sees an improvement on the way I am trying
> to pull this off.
>
> My concept is to use this browser detection only to warn people who
> have a browser less than what I consider standard but not prevent
> them from trying anyhow. Bascially if I detect something that is not
> at least of a certain version than I tell them to download a new
> version. I am targeting browsers that will allow decent support of
> CSS, support for JavaScript 1.2 (though I know IE has its own
> quirkiness in its use of JScript), and in general HTML 4.0.
Ok I'm not a fan of browser detection scripts. What I think is preferable is
'object detection' not browser detection.
What we have now is some degree of convergence (ie5+ ns6 (and I am told
opera4+ sometime soon )) in w3c dom support. So now it is possible to go
if(document.getElementsByTagName)
{
document.getElementById('xyz').style.color = 'blue'
}
and this will work in ns6 and ie5 but will be ignored by ie4 and ns4 for
lack of dom support.
Hopefully in the end maybe 5 years on we will have full w3c DOM -CSS
compliance in the major browsers so what is needed now detection of some
form of dom compliance and script accordingly.
So what i use now is a DOM detection script that goes.
function domDetect(){
if(document.getElementsByTagName)
{//DOM1 compliance ns6 and ie5 and anytime soon opera 4+
return 'dom';
}
if (document.all)
{//ie4 all DOM
return 'ie5';
}
if(document.images)
{//ns4
return 'preDom';
}
}
More information about the thelist
mailing list