From: Dr J R Stockton on
In comp.lang.javascript message <e4WdnckhUoAkZXbXnZ2dnUVZ8s-
dnZ2d(a)brightview.com>, Sat, 31 Oct 2009 08:43:31, Swifty
<steve.j.swift(a)gmail.com> posted:
>I know that detecting the browser is frowned upon here, but I have a
>need to identify specifically Internet Explorer 6.

Testing either
(0.007).toFixed(2)
or
S = "3000000000000000000000000" ; parseFloat(S+".0")/parseFloat(S)
will identify IE : the second in at least IE 4 to IE 8, and the first in
all versions from the introduction of toFixed to IE 8. Use those in
addition to conditional compilation, and you have belt-and-braces.

There is, I suppose, some risk of MS correcting those bugs; but that
will not worry you.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
From: David Mark on
On Oct 31, 6:21 pm, Dr J R Stockton <reply0...(a)merlyn.demon.co.uk>
wrote:
> In comp.lang.javascript message <e4WdnckhUoAkZXbXnZ2dnUVZ8s-
> dn...(a)brightview.com>, Sat, 31 Oct 2009 08:43:31, Swifty
> <steve.j.sw...(a)gmail.com> posted:
>
> >I know that detecting the browser is frowned upon here, but I have a
> >need to identify specifically Internet Explorer 6.
>
> Testing either
>     (0.007).toFixed(2)
> or
>     S = "3000000000000000000000000" ; parseFloat(S+".0")/parseFloat(S)
> will identify IE : the second in at least IE 4 to IE 8, and the first in
> all versions from the introduction of toFixed to IE 8.  Use those in
> addition to conditional compilation, and you have belt-and-braces.
>
> There is, I suppose, some risk of MS correcting those bugs; but that
> will not worry you.
>

What should worry you is other implementations with similar bugs. If
you have to come up with an object inference for IE (you don't in this
case), there are better tests than this. The OP wants to target 6 and
we know that XMLHttpRequest was not introduced until 7. Combine that
with detection of ActiveXObject, window.external,
document.documentElement.filters,
document.documentElement.style.filter, document.expando, etc. and you
can be pretty sure you've got IE6 (or at least its version of MSHTML),
for what that's worth (nothing in most cases).
From: Eric Bednarz on
David Mark <dmark.cinsoft(a)gmail.com> writes:

> […] The OP wants to target 6 and
> we know that XMLHttpRequest was not introduced until 7. Combine that
> with detection of ActiveXObject, window.external,
> document.documentElement.filters,
> document.documentElement.style.filter, document.expando, etc. and you
> can be pretty sure you've got IE6

If it *has* to be script based for some reason, I'd rather combine that
with conditional compilation. And then only if a false positive would
just result in an unnecesary performance hit (e.g. using filters where
it isn't necessary), because we also know that the native XMLHttpRequest
object can be disabled in the IE 7/8 preferences.
From: VK on
David Mark wrote:
> The OP wants to target 6 and
> we know that XMLHttpRequest was not introduced until 7.  Combine that
> with detection of ActiveXObject, window.external,
> document.documentElement.filters,
> document.documentElement.style.filter, document.expando, etc. and you
> can be pretty sure you've got IE6 (or at least its version of MSHTML)

Before I thought that your preferred way to change a light bulb is to
turn yourself around the lamp (your "feature detection" stuff was
rather convincing on that). Now I see that I was mistaken: if you are
in the misfortune to change a light bulb then you have to call someone
so to sit on his shoulders and ask him to turn around while you are
holding the bulb.
The correct documented and absolutely reliable way was already given
(conditional comments and/or conditional compilation). It comes with
vendor's documentation on version vector as well:
http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx#Version_Vectors
For Validator concerned also see "Valid HTML for downlevel-revealed
conditional comments" in comments at the bottom of the page.


From: Swifty on
RobG wrote:
> If this is for an intranet, the reason IE is being used is probably
> because it was the corporate standard. Your message should be honest,
> something like:
>
> "You seem to be using IE 6. It is no longer the standard corporate
> browser, please upgrade to one of <list suitable browsers>."

Very perspicacious of you; yes, it will be deployed on our Intranet.
Unfortunately it *is* still the default browser for those with Windows.
Firefox will become the default in just over 6 months. I'm just hoping
to persuade people to help me test my pages before the "big bang" day. :-)
I know that my pages work when one person uses them (me), and I know
that they work when a few thousand people use them (courtesy of the
server access logs). What worries me is when I suddenly have to deal
with 100's of thousands of them, prying into all the obscure niches of
my hopelessly primitive JavaScript.

It remains true that my page is much better viewed with Firefox, if only
for performance reasons, but I'm trying not to be partisan, hence
"better with almost anything except IE6". I will give a pointer to our
internal download site for Firefox though, as I wish to be seen toeing
the corporate line. Looks better in the annual review.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk