January 13, 2004

Javascript within your CSS

I ran across something interesting the other day that I had overlooked. Anne van Kesteren showed how Peter Nederlof came up a method to force Win IE to correctly display :hover elements. Ben Nolan also came up with a solution to this. But Ben embedded the javascript right within the CSS. By using background: url("javascript: ...), you can now put javascript right within your IE to recognize :hover elements. Rather, I think this could fix a great deal of positioning problems, width/height problems, and a bunch more stuff that I'm not even thinking of. I'm going to have to noodle this one over some more. I'll defintely be playing around with it.
Post Info

Tagged As CSS, Javascript

Comments are Open (3)

Posted at 07:33 AM

Comments

snigel

Just when I thought I had seen everything using expression() in CSS. That's one of the coolest CSS hacks I've seen in a long time.

$500 for the person that comes up with a CSS hack that uninstalls IE on your computer, and installes Firebird. That should fix the :hover problem in IE.

rob

using expressions with "this.something" you can fake attribute selectors too. pretty cool. course, jury's out on if you want to be using such extreme IE-specific hacks, but that's another conversation altogether.

Tony

The thing that I keep coming back to with this is height and width. I could just declare the id in CSS, and then use the DOM to get the proper width and size. And once I have the master DIV sizes, just use percentages for the interior stuff.

I just love the fact that I can put javascript in my css if needed.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu