> > 1. The script only looks for declarations in the stylesheets, that's the > > beauty of it. > yes, but I mean that if you look at the content of the cssRules > variable you will see that there are a lot of css declaration which > could be avoided (or they can't ?)
Christian, Ok, here's what I meant : In parseCss(), checking if css selector contains ":hover" (and return if not) will only do stuff on css selectors where :hover is present. I guess in most cases this is what we want. (correct me if I'm wrong). It's quite faster (I can feel it because I've got a 1ghz laptop :-) Anyway, here's a version of your script where we can choose if stuff should be done only for :hover selectors or not. Calling $.ie6HoverFix(); has the normal behaviour as you designed it. Calling $.ie6HoverFix(true); will redo css declaration only for :hover selectors Here it is. What do you think ? // ie6HoverFix - Author : Christian Bach $.ie6HoverFix = function(only_hovers) { if ($.browser.msie && $.browser.version < 7) { only_hovers = only_hovers || false; var cssRules = [], newStyleSheet = document.createStyleSheet(), styleSheets = document.styleSheets; function parseCSS(rule) { var prefix = "ie6fix-"; var select = rule.selectorText, style = rule.style.cssText; if (only_hovers && select.indexOf(":hover") == -1) { return; } var element = select.replace(/:(hover).*$/, ''); var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, '$1'); var styleRule = element + "." + prefix + pseudo; var className = prefix + pseudo; $(element).hover(function(e) { $(this).addClass(className); }, function(e) { $(this).removeClass(className) }); cssRules.push([styleRule,style]); } for (var i = 0, ii = styleSheets.length; i < ii; i++) { for(var j = 0, jj = styleSheets[i].rules.length; j < jj; j++) { parseCSS(styleSheets[i].rules[j]); } } for (var i = 0, ii = cssRules.length; i < ii; i++) { var ruledef = cssRules[i][1]; if (ruledef.length != 0) { newStyleSheet.addRule(cssRules[i][0], ruledef); } } } }; -- Fabien Meghazi Website: http://www.amigrave.com Email: [EMAIL PROTECTED] IM: [EMAIL PROTECTED]