473,395 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #1
7 1389
Michael Winter <M.******@blueyonder.co.invalid> 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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
On Tue, 03 Feb 2004 23:40:35 +0100, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
Michael Winter <M.******@blueyonder.co.invalid> 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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
DU
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
Jul 20 '05 #4
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
Jul 20 '05 #5
On Tue, 03 Feb 2004 19:15:39 -0500, DU <dr*******@hotWIPETHISmail.com>
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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #6
On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <vl**@klproductions.com> 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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #7
On Wed, 04 Feb 2004 01:52:29 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:
On Wed, 04 Feb 2004 00:53:08 GMT, Vladdy <vl**@klproductions.com> 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/

Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Szar | last post by:
JS noob. I've seen plenty of browser detection scripts but they all seem to be slightly different and don't really fit my needs. I have various places where if the browser is IE I'd like to display...
17
by: lawrence | last post by:
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...
8
by: R. Smits | last post by:
I've have got this script, the only thing I want to be changed is the first part. It has to detect IE version 6 instead of just "Microsoft Internet Explorer". Can somebody help me out? I tried...
13
by: ima | last post by:
Where can I find a list of valid names for Navigator.AppName?
7
by: phal | last post by:
Hi I think there are many different browsers to browse to the Internet, how can I write the javascript to identify different browser and display according to the users. Some browser disable the...
4
by: trpost | last post by:
I am looking for a script using javascript to pull browser information including, browser type and version, OS info, plugins (flash, acrobat, media player, etc), java version, etc. that will work...
15
by: CMM | last post by:
So I'm half way through overseeing a large project in ASP.NET 2.0. My superiors have decided that it would be nice if we ensured the site worked on all the major platforms (as they see it: IE,...
16
by: petermichaux | last post by:
Hi, Does anyone have a a cross-browser setOpacity function that does not use browser sniffing? I looked at the Yahoo! UI function and it detects IE by looking for window.ActiveXObject. I also...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.