Hover Pseudoclass For Anything in IE

2005-07-16 13:12 - Web

This is not my original work, but I wanted to make very sure I never lost it. Klaus Hartl posted this to the css-d discussion list on July 10th:

Hi all,

this may be of some interest here... I found a way to easily implement
whatever:hover using Dynamic Properties. Here's an example of the code:

..whatever {
     background: #808080;
..whatever:hover, .whateverhover {
     background: #eaeaea;

..whatever {
     background-color: expression(this.runtimeStyle.backgroundColor,
this.onmouseover = function() { this.className += ' whateverhover'; },
this.onmouseout = function() { this.className =
this.className.replace('whateverhover', ''); });

It looks odd, but it works!

Here's a demo page:
....and a blog entry of mine about all this:

Happy Coding,


This is rather exciting. IE's total lack of support for things like :hover and min-width and so forth can now be made to function much better!


No comments!

Post a comment:

  If you do not have an account to log in to yet, register your own account. You will not enter any personal info and need not supply an email address.

You may use Markdown syntax in the comment, but no HTML. Hints:

If you are attempting to contact me, ask me a question, etc, please send me a message through the contact form rather than posting a comment here. Thank you. (If you post a comment anyway when it should be a message to me, I'll probably just delete your comment. I don't like clutter.)