Main /

Java Script

Machine

Art

Social

Admin

edit SideBar

Java Script

Menu Highlighting weirdness

Was working with some JavaScript to get a basic menu set up for the site. It was basically for highlighting focussed items and stuff. As it were, I was using the onMouseOver and onMouseOut events to restore the style of a bar. The onMouseOver handler would store the existing state of the bar in a variable before changing its style and the onMouseOut one would restore it from that stored value. Also, the currently selected (not the one my mouse was over) menu option would be a different selected style.

Which worked fine. But then I noticed that if I clicked a menu option and moved down very fast through the other menu option, the clicked menu option would not go to the selected style.

A little head-scratching and I figured that the answer is that the state gets somehow 'corrupted' when I do this really fast. Apparently, the onMouseOver handler is called on one page but the onMouseOut handler is called on a different page (because I moved really fast). And of course the state of the new page is not set to anything.

The above explanation seems fuzzy to me. Anyway, I removed the dependence on state and now it works quite well.

Recent Changes (All) | Edit SideBar Page last modified on May 31, 2007, at 05:29 AM Edit Page | Page History
Powered by PmWiki