A valid use for browser detection?

Discussion in 'Javascript' started by Michael Winter, Feb 3, 2004.

  1. As many of you know, IE has poor support for CSS 2, including the dynamic
    pseudo-class, :hover. This could easily be emulated with an intrinsic
    event, but how can you tell that it's required? You could skip the
    detection by always adding an event handler but this would be a waste of
    time for browsers that do implement the pseudo-class.

    Any suggestions? Would it be best to avoid the :hover pseudo-class and
    implement a full event-based solution, or is there a way to detect
    support? Can this be extended to other CSS selectors, and even
    declarations?

    Mike

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
     
    Michael Winter, Feb 3, 2004
    #1
    1. Advertising

  2. Michael Winter <> writes:

    > As many of you know, IE has poor support for CSS 2, including the
    > dynamic pseudo-class, :hover. This could easily be emulated with an
    > intrinsic event, but how can you tell that it's required?


    Only by precisely detecting IE 6 or older.
    For IE 5.5 and later, you can use conditional comments (currently not
    implemented by any other browser afaik), or you can use behaviors
    (<URL:http://msdn.microsoft.com/workshop/author/behaviors/overview.asp>).

    > You could skip the detection by always adding an event handler but
    > this would be a waste of time for browsers that do implement the
    > pseudo-class.


    Yes, using Javascript should only ever be a fallback for older browsers
    where you know that it will work. New browsers are supposed to get it right,
    and should by default not be included in the fallback.

    > Any suggestions? Would it be best to avoid the :hover pseudo-class


    No, use the standard, that's what it is there for.

    > and implement a full event-based solution,


    Only if you want to. Your page should work without it, since you can't
    expect Javascript to be available either.

    > or is there a way to detect support? Can this be extended to other
    > CSS selectors, and even declarations?


    Probably :)
    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Feb 3, 2004
    #2
    1. Advertising

  3. On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen
    <> wrote:

    > Michael Winter <> writes:
    >
    >> As many of you know, IE has poor support for CSS 2, including the
    >> dynamic pseudo-class, :hover. This could easily be emulated with an
    >> intrinsic event, but how can you tell that it's required?

    >
    > Only by precisely detecting IE 6 or older.
    > For IE 5.5 and later, you can use conditional comments (currently not
    > implemented by any other browser afaik), or you can use behaviors
    > (<URL:http://msdn.microsoft.com/workshop/author/behaviors/overview.asp>).


    I thought it might involve something nasty like that.

    >> You could skip the detection by always adding an event handler but
    >> this would be a waste of time for browsers that do implement the
    >> pseudo-class.

    >
    > Yes, using Javascript should only ever be a fallback for older browsers
    > where you know that it will work. New browsers are supposed to get it
    > right, and should by default not be included in the fallback.
    >
    >> Any suggestions? Would it be best to avoid the :hover pseudo-class

    >
    > No, use the standard, that's what it is there for.


    I completely agree with both of these points, and they represent my
    preferred approach. However, if someone were to argue a valid case against
    it, I'd be prepared to accept it. Thankfully, you didn't. :) Here's hoping
    no-one else does...

    >> and implement a full event-based solution,

    >
    > Only if you want to.


    I'd really rather not. IE users can do without, until that cold day in
    Hell when Microsoft implements CSS 2. It won't degrade their use of the
    site, either way.

    > Your page should work without it, since you can't
    > expect Javascript to be available either.


    Of course.

    >> or is there a way to detect support? Can this be extended to other
    >> CSS selectors, and even declarations?

    >
    > Probably :)


    A nice and concrete answer, there. :p

    I was really looking for a simple solution that I might have overlooked,
    but it would appear that any detection would involve something convoluted
    that I could do without.

    Unless someone else has something different to add, I think that would
    conclude this thread.

    Thank you, Mr Nielsen.

    Mike

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
     
    Michael Winter, Feb 3, 2004
    #3
  4. Michael Winter

    DU Guest

    Michael Winter wrote:
    > As many of you know, IE has poor support for CSS 2, including the
    > dynamic pseudo-class, :hover.


    No, I did not know that. AFAIK, a:hover always was well supported by MSIE 6.

    This could easily be emulated with an
    > intrinsic event, but how can you tell that it's required? You could skip
    > the detection by always adding an event handler but this would be a
    > waste of time for browsers that do implement the pseudo-class.
    >
    > Any suggestions? Would it be best to avoid the :hover pseudo-class and
    > implement a full event-based solution, or is there a way to detect
    > support? Can this be extended to other CSS selectors, and even
    > declarations?
    >
    > Mike
    >


    You could build a custom behavior for this and include it in a
    stylesheet... or you could create an accurate custom script function to
    compensate such MSIE absence of support... or you could give an url and
    explain what exactly you're trying to achieve.

    DU
     
    DU, Feb 4, 2004
    #4
  5. Michael Winter

    Vladdy Guest

    Michael Winter wrote:
    > On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen
    > <snip />

    or you can use behaviors
    >> (<URL:http://msdn.microsoft.com/workshop/author/behaviors/overview.asp>).

    > I thought it might involve something nasty like that.
    > <snip />
    > Mike
    >


    Actually using behaviors is not difficult at all:
    http://www.vladdy.net/Demos/IEPseudoClassesFix.html

    --
    Vladdy
    http://www.klproductions.com
     
    Vladdy, Feb 4, 2004
    #5
  6. On Tue, 03 Feb 2004 19:15:39 -0500, DU <>
    wrote:

    > Michael Winter wrote:
    >> As many of you know, IE has poor support for CSS 2, including the
    >> dynamic pseudo-class, :hover.

    >
    > No, I did not know that. AFAIK, a:hover always was well supported by
    > MSIE 6.


    The :hover pseudo-class applies to virtually every HTML element, not just
    anchors. You could apply it to a DIV, a TABLE, a list. You can even apply
    it to BODY. I think the only exceptions would be HEAD-based elements (for
    obvious reasons) and SCRIPT elements.

    As a matter of fact, a:hover works with IE 5.5, too but only if you use
    a:hover. #an-anchor:hover fails.

    [snip]

    > You could build a custom behavior for this and include it in a
    > stylesheet... or you could create an accurate custom script function to
    > compensate such MSIE absence of support... or you could give an url and
    > explain what exactly you're trying to achieve.


    The missing functionality isn't important enough to require such dogged
    attempts to compensate for IE's shortcomings. It was also a general
    question that revolved around CSS feature support in general: if the
    principals of script feature detection could be applied in some fashion.

    Thank you for the suggestions, however. If it was more mission critical, I
    would certainly investigate them further, but the effort simply isn't
    justified.

    Mike

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
     
    Michael Winter, Feb 4, 2004
    #6
  7. On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <> wrote:

    > Michael Winter wrote:
    >> On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen <snip />

    > or you can use behaviors
    >>> (<URL:http://msdn.microsoft.com/workshop/author/behaviors/overview.asp>).

    >> I thought it might involve something nasty like that.
    > > <snip />
    >> Mike
    >>

    >
    > Actually using behaviors is not difficult at all:
    > http://www.vladdy.net/Demos/IEPseudoClassesFix.html


    I suppose I did just dismiss them out of hand, but it seems so
    unreasonable to ask developers to use such an obscure method of doing
    something that most other browsers can do the simple way.

    Thank you for sharing that page.

    Mike


    By the way, para. 1, sentence 1 should read: "...forced onto the
    unsuspecting public by Microsoft Corporation..." :)

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
     
    Michael Winter, Feb 4, 2004
    #7
  8. Michael Winter

    Jim Ley Guest

    On Wed, 04 Feb 2004 01:52:29 GMT, Michael Winter
    <> wrote:

    >On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <> wrote:
    >
    >> Michael Winter wrote:
    >>> On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen <snip />

    >> or you can use behaviors
    >>>> (<URL:http://msdn.microsoft.com/workshop/author/behaviors/overview.asp>).
    >>> I thought it might involve something nasty like that.
    >> > <snip />
    >>> Mike
    >>>

    >>
    >> Actually using behaviors is not difficult at all:
    >> http://www.vladdy.net/Demos/IEPseudoClassesFix.html

    >
    >I suppose I did just dismiss them out of hand, but it seems so
    >unreasonable to ask developers to use such an obscure method of doing
    >something that most other browsers can do the simple way.


    Behaviors are not recommended by microsoft any more, they suffer from
    terrible memory leaks and are truly awful. Avoid!

    Jim.
    --
    comp.lang.javascript FAQ - http://jibbering.com/faq/
     
    Jim Ley, Feb 4, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Townsend

    browser detection for mobile devices

    Phil Townsend, Dec 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    747
    bruce barker
    Dec 2, 2004
  2. Carlos
    Replies:
    4
    Views:
    21,963
    amimpat
    Aug 11, 2009
  3. jaydev

    browser detection and redirection

    jaydev, Oct 23, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    467
    Mark Rae
    Oct 23, 2006
  4. jaydev
    Replies:
    41
    Views:
    1,639
    Chaddy2222
    Oct 27, 2006
  5. Replies:
    4
    Views:
    105
    Dr John Stockton
    Dec 10, 2003
Loading...

Share This Page