Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > A valid use for browser detection?

Reply
Thread Tools

A valid use for browser detection?

 
 
Michael Winter
Guest
Posts: n/a
 
      02-03-2004
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
http://www.velocityreviews.com/forums/(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      02-03-2004
Michael Winter <(E-Mail Removed)> 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 - (E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      02-03-2004
On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen
<(E-Mail Removed)> wrote:

> Michael Winter <(E-Mail Removed)> 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.

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
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
DU
Guest
Posts: n/a
 
      02-04-2004
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
 
Reply With Quote
 
Vladdy
Guest
Posts: n/a
 
      02-04-2004
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
 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      02-04-2004
On Tue, 03 Feb 2004 19:15:39 -0500, DU <(E-Mail Removed)>
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
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      02-04-2004
On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <(E-Mail Removed)> 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
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
Jim Ley
Guest
Posts: n/a
 
      02-04-2004
On Wed, 04 Feb 2004 01:52:29 GMT, Michael Winter
<(E-Mail Removed)> wrote:

>On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <(E-Mail Removed)> 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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use RegularExpressionValidator to valid if a date ad ASP .Net 2 05-04-2005 12:02 AM
Re: Valid form element names? How to use ID instead of name? Processing form data Michael Winter HTML 4 03-06-2004 10:21 PM
Re: Valid form element names? How to use ID instead of name? Processing form data Jukka K. Korpela HTML 3 03-06-2004 04:30 PM
Re: Valid form element names? How to use ID instead of name? Processingform data DU HTML 0 03-06-2004 02:44 PM
valid use of instanceof or a better way? VisionSet Java 13 11-18-2003 10:08 PM



Advertisments