tags:

views:

162

answers:

2

The site is http://greenvillenext.com/site (NOTE: please ignore the crazy load times and everything, I already know).

Here's what's going on: clicking an item in the main navigation (the five links across the top) gives that item a class of "active" and when you click a different one it removes the active class from that one and adds it to the new one. Obviously, this active class is used to style the nav link to let you know where you are.

However, in IE7, clicking on a different link in the nav doesn't remove the active style from the previously active link until you hover over it, which seems to reset it.

I'm at a loss here. I've tried any kind of peek-a-boo hack that I could find (min-width: 0 for example), I've set an 'inactive' class to non-active links and styled that differently, etc. Nothing seems to make it reset until you hover over it in IE7.

Any ideas?

A: 

How are you defining the hover? The easiest (and most reliable way), is to use jQuery.

$('.myNav').hover( function(){

$('.myNav').removeAttr //remove whatever styling hover causes
$(this).css //set the background/do hover animation

});

You would need a way to flag the currently selected tab and ignore it; you could always use some attribute on the elements to flag such. I see that your nav elements are all different classes; I'd add another class to all of them for easy grouping.

To all the jQuery naysayers: he's already using jQuery-UI, so the addition of the jQuery plugin is a moot issue. This will be more readable and probably efficient than any homerolled solution.

Stefan Kendall
I'm just using the :hover pseudoclass in my CSS. Is there some reason I'm unaware of why hover states should be done in JS?
Mike Crittenden
If you want to hover anything that's not an anchor, you'll need to use javascript for IE compatibility. This also completely removes any possibility of cross-browser CSS rendering issues, which are many.
Stefan Kendall
Don't think it's the hover that's causing the issue. Seems like IE is not respecting the fact that the "active" class is being removed via JS, and it doesn't realize it until you hover over it (which resets it).
Mike Crittenden
Have you tried removing the active class on click or hover, like I suggested?$('.myNav').removeClass( 'active' );
Stefan Kendall
It's already set up so that clicking any nav element removes the active class from whichever nav element previously had the active class. A hover shouldn't have anything to do with it.Apologies if I'm misunderstanding you.
Mike Crittenden
Is the selector not working in IE7? Have you tried blanket removing the active class like I proposed?
Stefan Kendall
A: 

Turns out, it was the fact that the designer had enabled DD_belatedPNG for all versions of IE instead of just IE6, and that was the culprit.

Mike Crittenden