A valid use for browser detection?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Winter

    A valid use for browser detection?

    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
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
  • Lasse Reichstein Nielsen

    #2
    Re: A valid use for browser detection?

    Michael Winter <M.Winter@bluey onder.co.invali d> writes:
    [color=blue]
    > 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?[/color]

    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>).
    [color=blue]
    > 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.[/color]

    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.
    [color=blue]
    > Any suggestions? Would it be best to avoid the :hover pseudo-class[/color]

    No, use the standard, that's what it is there for.
    [color=blue]
    > and implement a full event-based solution,[/color]

    Only if you want to. Your page should work without it, since you can't
    expect Javascript to be available either.
    [color=blue]
    > or is there a way to detect support? Can this be extended to other
    > CSS selectors, and even declarations?[/color]

    Probably :)
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Michael Winter

      #3
      Re: A valid use for browser detection?

      On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen
      <lrn@hotpop.com > wrote:
      [color=blue]
      > Michael Winter <M.Winter@bluey onder.co.invali d> writes:
      >[color=green]
      >> 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?[/color]
      >
      > 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>).[/color]

      I thought it might involve something nasty like that.
      [color=blue][color=green]
      >> 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.[/color]
      >
      > 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.
      >[color=green]
      >> Any suggestions? Would it be best to avoid the :hover pseudo-class[/color]
      >
      > No, use the standard, that's what it is there for.[/color]

      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...
      [color=blue][color=green]
      >> and implement a full event-based solution,[/color]
      >
      > Only if you want to.[/color]

      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.
      [color=blue]
      > Your page should work without it, since you can't
      > expect Javascript to be available either.[/color]

      Of course.
      [color=blue][color=green]
      >> or is there a way to detect support? Can this be extended to other
      >> CSS selectors, and even declarations?[/color]
      >
      > Probably :)[/color]

      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
      M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

      Comment

      • DU

        #4
        Re: A valid use for browser detection?

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

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

        This could easily be emulated with an[color=blue]
        > 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
        >[/color]

        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

        Comment

        • Vladdy

          #5
          Re: A valid use for browser detection?

          Michael Winter wrote:[color=blue]
          > On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen
          > <snip />[/color]
          or you can use behaviors[color=blue][color=green]
          >> (<URL:http://msdn.microsoft. com/workshop/author/behaviors/overview.asp>).[/color]
          > I thought it might involve something nasty like that.
          > <snip />
          > Mike
          >[/color]

          Actually using behaviors is not difficult at all:


          --
          Vladdy

          Comment

          • Michael Winter

            #6
            Re: A valid use for browser detection?

            On Tue, 03 Feb 2004 19:15:39 -0500, DU <drunclear@hotW IPETHISmail.com >
            wrote:
            [color=blue]
            > Michael Winter wrote:[color=green]
            >> As many of you know, IE has poor support for CSS 2, including the
            >> dynamic pseudo-class, :hover.[/color]
            >
            > No, I did not know that. AFAIK, a:hover always was well supported by
            > MSIE 6.[/color]

            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]
            [color=blue]
            > 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.[/color]

            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
            M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

            Comment

            • Michael Winter

              #7
              Re: A valid use for browser detection?

              On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <vlad@klproduct ions.com> wrote:
              [color=blue]
              > Michael Winter wrote:[color=green]
              >> On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen <snip />[/color]
              > or you can use behaviors[color=green][color=darkred]
              >>> (<URL:http://msdn.microsoft. com/workshop/author/behaviors/overview.asp>).[/color]
              >> I thought it might involve something nasty like that.
              > > <snip />
              >> Mike
              >>[/color]
              >
              > Actually using behaviors is not difficult at all:
              > http://www.vladdy.net/Demos/IEPseudoClassesFix.html[/color]

              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
              M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

              Comment

              • Jim Ley

                #8
                Re: A valid use for browser detection?

                On Wed, 04 Feb 2004 01:52:29 GMT, Michael Winter
                <M.Winter@bluey onder.co.invali d> wrote:
                [color=blue]
                >On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <vlad@klproduct ions.com> wrote:
                >[color=green]
                >> Michael Winter wrote:[color=darkred]
                >>> On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen <snip />[/color]
                >> or you can use behaviors[color=darkred]
                >>>> (<URL:http://msdn.microsoft. com/workshop/author/behaviors/overview.asp>).
                >>> I thought it might involve something nasty like that.
                >> > <snip />
                >>> Mike
                >>>[/color]
                >>
                >> Actually using behaviors is not difficult at all:
                >> http://www.vladdy.net/Demos/IEPseudoClassesFix.html[/color]
                >
                >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.[/color]

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

                Jim.
                --
                comp.lang.javas cript FAQ - http://jibbering.com/faq/

                Comment

                Working...