Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

mouse out and mouse over problem in IE

Posted on 2009-04-13
2
Medium Priority
?
395 Views
Last Modified: 2013-12-08
hello,
i have a navigation using the tag UL and i want the item in the list to change class on mouse over and go back to the original class on mouseout, the problem is when i'm using IE and the mouse is over an inline element like A or IMG tags  inside the LI then the browser calls to mouseout event.
in the Code section u can see the HTML and the JS code.(using Prototype Framework)
<ul id="navigation-right" class="clearfix">
<li class="not-selected"><img id="Img1"  src="../images/new_design/general/Icon_Add.gif" alt="poll" /><a href="PollAdd.aspx" class="Blue" onclick="return loginState();">add poll</a></li>
<li class="not-selected"><img id="Img3"  src="../images/new_design/navigation_icons/Icon_Survey.gif" alt="poll" /><asp:HyperLink ID="hylMyArticles" runat="Server" CssClass="Blue" onclick="return loginState();">view pollsÙ</asp:HyperLink></li>
</ul>
~~~~
        var navigationHandler = {
            addMouseEvents : function(ul){
                var arrLi = $(ul).childElements();
                for(var i=0;i<arrLi.length;i++){
                    navigationHandler.addEvents(arrLi[i],'mouseover','selected');
                    navigationHandler.addEvents(arrLi[i],'mouseout','not-selected');
                }
            },addEvents : function(obj,eventType,cssClass){
                Element.observe(obj,eventType,function(){
                    var elm = navigationHandler.getElement.apply(this);
                    elm.className = cssClass;
                });
            },getElement : function(){
                var elm = null;
                if(document.all){
                    var e = window.event;
                    elm = e.srcElement;
                    if(e.type.toLowerCase() == 'mouseout'){
                        if(((e.toElement.tagName.toLowerCase() == 'img') || (e.toElement.tagName.toLowerCase() == 'a')) && (e.fromElement.tagName != 'li' )){
                            return false;
                        }
                    }
                }else {elm = this}
                return elm ;
            }
        }

Open in new window

0
Comment
Question by:mekusharim_ltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
JPJ78 earned 2000 total points
ID: 24128862
Have a look at this.

http://blog.stchur.com/2007/03/15/mouseenter-and-mouseleave-events-for-firefox-and-other-non-ie-browsers/

The trick is to use:
relatedTarget, fromElement, toElement
to see if element that raises the event is a child of the element who already has risen the event.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question