[Javascript] RES: (no subject)

Scott Reynen scott at randomchaos.com
Wed Aug 29 18:37:50 CDT 2007


On Aug 29, 2007, at 5:17 PM, liorean wrote:

>>>> var ie=(document.all);
>>
>>> Browser sniffing is far too fragile - I suggest you use object
>>> detection instead.
>>
>> Uh, that *is* "object detection", is it not??
>
> Nope. Object detection means you are detecting whether objects you can
> use for different paths exist. But this is not used that way - sure,
> it's still detecting whether objects exists, but not for the purpose
> of choosing whether to use them or use another path. This is just
> using detection of objects to try to determine which browser is
> running, and then choosing path based on browser.

But when the path chosen "based on the browser" is entirely  
restricted to the objects being tested, the two are functionally  
identical.  I suspect you're just getting distracted by the variable  
names.  What if we changed

var ie=(document.all);
[...]
if(ie) object=eval('document.all.'+element+'.style');

to

var supportsDocumentAll=(document.all);
[...]
if(supportsDocumentAll) object=eval('document.all.'+element+'.style');

Would you still call that browser sniffing?

Peace,
Scott




More information about the Javascript mailing list