Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   things missing from the FAQs: which browser is this (http://www.velocityreviews.com/forums/t879857-things-missing-from-the-faqs-which-browser-is-this.html)

lawrence 10-01-2004 08:33 AM

things missing from the FAQs: which browser is this
 
How is it possible that the question "How do I detect which browser
the user has" is missing from this FAQ:

http://www.faqts.com/knowledge_base/index.phtml/fid/125

and is only here on this with a link to old information that suggests
use of "navigator":


http://developer.irt.org/script/43.htm

Lee 10-01-2004 08:52 AM

Re: things missing from the FAQs: which browser is this
 
lawrence said:
>
>How is it possible that the question "How do I detect which browser
>the user has" is missing from this FAQ:
>
>http://www.faqts.com/knowledge_base/index.phtml/fid/125
>
>and is only here on this with a link to old information that suggests
>use of "navigator":
>
>
>http://developer.irt.org/script/43.htm


Because it's generally a bad idea to try to guess which browser
the user has. That's rarely useful information. Different
versions of the same browser may be very different, and the same
version may behave differently on different platforms or with
different user preferences. The navigator attribute can't be
trusted even to reliably report the browser name.

It's better to detect whether or not the browser your code is
running in supports whatever specific features you're interested
in.


kaeli 10-01-2004 02:01 PM

Re: things missing from the FAQs: which browser is this
 
In article <da7e68e8.0410010033.4315526f@posting.google.com >,
lkrubner@geocities.com enlightened us with...
> How is it possible that the question "How do I detect which browser
> the user has" is missing from this FAQ:
>
> http://www.faqts.com/knowledge_base/index.phtml/fid/125
>


Browser detection for anything other than IE using the proprietary IE
conditional code is bound to fail horribly.
They should have that question there with all the reasons why one *shouldn't*
do it.

No one with any experience does browser detection any more. That's a
throwback from the days when only IE and Netscape were around.
Use object detection instead.

--
--
~kaeli~
Murphy's Law #2030: If at first you don't succeed, destroy
all evidence that you tried.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


Michael Winter 10-01-2004 03:20 PM

Re: things missing from the FAQs: which browser is this
 
On Fri, 01 Oct 2004 15:09:59 GMT, Andrew Thompson <SeeMySites@www.invalid>
wrote:

[snip]

> <testing recently gained knowledge>
> The term 'object detection' should really be changed to
> 'feature detection', as to say 'object detection' without
> qualification leads to confusion between 'feature detection'
> and 'object inference'* ( which is a bad thing, ..mmkay? ;-).
> </testing recently gained knowledge>


I'd agree that it's a better term. Feature detection applies to testing
the presence - and possibly the behaviour - of objects, methods and
properties. Object detection seems more limited in scope.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

kaeli 10-01-2004 06:35 PM

Re: things missing from the FAQs: which browser is this
 
In article <opse659ucvx13kvk@atlantis>, M.Winter@blueyonder.co.invalid
enlightened us with...
> On Fri, 01 Oct 2004 15:09:59 GMT, Andrew Thompson <SeeMySites@www.invalid>
> wrote:
>
> [snip]
>
> > <testing recently gained knowledge>
> > The term 'object detection' should really be changed to
> > 'feature detection', as to say 'object detection' without
> > qualification leads to confusion between 'feature detection'
> > and 'object inference'* ( which is a bad thing, ..mmkay? ;-).
> > </testing recently gained knowledge>

>
> I'd agree that it's a better term. Feature detection applies to testing
> the presence - and possibly the behaviour - of objects, methods and
> properties. Object detection seems more limited in scope.
>
> [snip]
>


Can one of you lovely gentlemen explain the difference please?

I know what *I* meant, but I'm not sure what you all mean. *smiles*

Is this object or feature detection:

if (document.getElementById)
{
e = document.getElementById("myDiv");
if (e.style.visibility)
{
e.style.visibility = "hidden";
}
}

To me, it's object detection, since I'm testing for objects and properties of
objects.
Feature detection seems too much like looking for plugins, to me, anyways. If
someone said "Feature detection", I'd think of Flash and applets, not DOM.
Could be my bad, though. My brain breaks now and then.

--
--
~kaeli~
Once you've seen one shopping center, you've seen a mall.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


Michael Winter 10-01-2004 07:02 PM

Re: things missing from the FAQs: which browser is this
 
On Fri, 1 Oct 2004 13:35:51 -0500, kaeli <tiny_one@NOSPAM.comcast.net>
wrote:

> In article <opse659ucvx13kvk@atlantis>, M.Winter@blueyonder.co.invalid
> enlightened us with...
>
>> On Fri, 01 Oct 2004 15:09:59 GMT, Andrew Thompson
>> <SeeMySites@www.invalid> wrote:
>>
>>> <testing recently gained knowledge>
>>> The term 'object detection' should really be changed to
>>> 'feature detection', as to say 'object detection' without
>>> qualification leads to confusion between 'feature detection'
>>> and 'object inference'* ( which is a bad thing, ..mmkay? ;-).
>>> </testing recently gained knowledge>

>>
>> I'd agree that it's a better term. Feature detection applies to testing
>> the presence - and possibly the behaviour - of objects, methods and
>> properties. Object detection seems more limited in scope.

>
> Can one of you lovely gentlemen explain the difference please?


We're not being too pedantic, are we? :P

> I know what *I* meant, but I'm not sure what you all mean. *smiles*


We all mean the same thing. :)

The debate here is that the phrase, object detection, seems too much like,
object inference. The latter being a form of browser detection which uses
one or more objects that the author thinks is unique to a browser (and
usually isn't).

> Is this object or feature detection:


I'd call it feature detection because you're not just looking at objects.
I also think it gives the clear indication that you're looking at the user
agent's capabilities.

> if (document.getElementById)
> {
> e = document.getElementById("myDiv");
> if (e.style.visibility)


I assume that this was a quick example, but I thought I'd mention that
that test might fail even when the visibility property is supported.
That's because the value could be an empty string, indicating that there
is no inline style in effect, and evaluate as false. Moreover, is misses a
crucial test: is the style object supported?

I'd write:

if(e && e.style) {

If that test passes, you can write to the visibility property. Nothing may
actually happen when you do so, but you can't really tell if it would,
anyway. If you did want an explicit check for the property, add

&& ('string' == e.style.visibility)

By this point, it might be worth saving a reference to the style object to
reduce look-ups.

[snip]

> To me, it's object detection, since I'm testing for objects and
> properties of objects.
> Feature detection seems too much like looking for plugins, to me,
> anyways. If someone said "Feature detection", I'd think of Flash and
> applets, not DOM.
> Could be my bad, though. My brain breaks now and then.


I suppose everyone reads into it a different way. The main thing would be
to make clear what the objective is: to test for functionality before
using it. As long as that message gets across, the method of delivery is
less important.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

kaeli 10-01-2004 08:25 PM

Re: things missing from the FAQs: which browser is this
 
In article <opse7gi5vjx13kvk@atlantis>, M.Winter@blueyonder.co.invalid
enlightened us with...
> >
> > Can one of you lovely gentlemen explain the difference please?

>
> We're not being too pedantic, are we? :P
>


Who, me?
*heh*

> > I know what *I* meant, but I'm not sure what you all mean. *smiles*

>
> We all mean the same thing. :)
>
> The debate here is that the phrase, object detection, seems too much like,
> object inference. The latter being a form of browser detection which uses
> one or more objects that the author thinks is unique to a browser (and
> usually isn't).
>


Ah, okay.
I know what you mean, but have never heard that term for it. I just
considered it a really bad way of doing browser detection. Actually, it's the
way I see it most, aside from the navigator object. And it usually fails
utterly in older versions of Opera, notably. *laughs*

> > Is this object or feature detection:

>
> I'd call it feature detection because you're not just looking at objects.
> I also think it gives the clear indication that you're looking at the user
> agent's capabilities.
>
> > if (document.getElementById)
> > {
> > e = document.getElementById("myDiv");
> > if (e.style.visibility)

>
> I assume that this was a quick example,


It was. A really, really quick example. I'd normally test for style, too.
But the tip about the empty string was interesting. I didn't think about that
one. Actually, I don't use the style object at all for my stuff, but couldn't
think of a quicker example to type at the time. *grins*

I still like the term 'object detection' better. Probably because I'm weird.

--
--
~kaeli~
Do not taunt Happy Fun Ball!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


Michael Winter 10-01-2004 09:03 PM

Re: things missing from the FAQs: which browser is this
 
On Fri, 01 Oct 2004 20:42:49 GMT, Andrew Thompson <SeeMySites@www.invalid>
wrote:

> On Fri, 1 Oct 2004 15:25:22 -0500, kaeli wrote:
>
>> In article <opse7gi5vjx13kvk@atlantis>,
>> M.Winter@blueyonder.co.invalid enlightened us with...


[snip]

>>> We're not being too pedantic, are we? :P

>>
>> Who, me?
>> *heh*


No, not at all.

> I think he was actually referring to me, but you can take
> the fall for it if you like. ..I'm easy. :-)


Me, certainly (par for the course, really :D ). You, if you feel like it.
After all, we're the only ones commenting about it at the moment.

>> I still like the term 'object detection' better.


There's always one...

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Randy Webb 10-01-2004 10:25 PM

Re: things missing from the FAQs: which browser is this
 
kaeli wrote:

<--snip-->

> Can one of you lovely gentlemen explain the difference please?


Object Detection, you are checking for the existence of an object, not
its methods. With feature detection (which I think should be called
"method detection") is when you are checking for a feature/method.

> I know what *I* meant, but I'm not sure what you all mean. *smiles*
>
> Is this object or feature detection:
>
> if (document.getElementById)


feature detection.

> {
> e = document.getElementById("myDiv");


if (e)

object detection.

> if (e.style.visibility)


Thats checking for a property.

> {
> e.style.visibility = "hidden";
> }
> }
>
> To me, it's object detection, since I'm testing for objects and properties of
> objects.
> Feature detection seems too much like looking for plugins, to me, anyways. If
> someone said "Feature detection", I'd think of Flash and applets, not DOM.
> Could be my bad, though. My brain breaks now and then.


If I could get my brain to work more than 2% of the time, I would be
overly ecstatic :)



--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq

Dr John Stockton 10-02-2004 12:13 PM

Re: things missing from the FAQs: which browser is this
 
JRS: In article <cjj5t408u0@drn.newsguy.com>, dated Fri, 1 Oct 2004
01:52:52, seen in news:comp.lang.javascript, Lee
<REM0VElbspamtrap@cox.net> posted :
>lawrence said:
>>
>>How is it possible that the question "How do I detect which browser
>>the user has" is missing from this FAQ:
>>
>>http://www.faqts.com/knowledge_base/index.phtml/fid/125
>>
>>and is only here on this with a link to old information that suggests
>>use of "navigator":
>>
>>
>>http://developer.irt.org/script/43.htm

>
>Because it's generally a bad idea to try to guess which browser
>the user has. That's rarely useful information.
> ...


That's an invalid refutation.

"How do I detect which browser the user has" *is*, in those or
sufficiently similar words, a frequently-enough asked question;
therefore, there should be a subject line in Sec. 4 that manifestly
corresponds - and the OP's wording seems as good as any (except that
"has" should be "is using"; consider "which browser does LRN have?").

Compare Section 4.1, "How do I protect my javascript code?".

The answer *should* include something on browser detection, since the
identity claim of the browser may be of legitimate interest whatever the
browser might be.

IMHO, a browser claiming to be FrogSpawn v.19 has a valid claim
to be treated as such; a user is entitled to the consequences of
his choices (note that, using feature detection, a page can be
made to show "You claim to be using FrogSpawn v.19; since method
'window.tadPole' does not exist, that is a manifest
terminological inexactitude.").

It's only nasty commercial sites that insist on ignoring such
statements in order to force their content through.

But the answer should include a paragraph on the merits of feature
detection, with perhaps a link to more detail, perhaps in the Notes.

IMHO, the FAQ should include a complete list of the Notes, linking.

I now see the Subject of 4.26 - it is too specific.

Sec 4.12 "Why does parseInt('09') give an error?" should cite 4.21, with
a statement that parseInt is used too often.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.


All times are GMT. The time now is 10:12 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.