Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
mouseover and mouseout acting strangely
Old 06-09-2008, 07:39 AM mouseover and mouseout acting strangely
Average Talker

Posts: 18
Name: Phil
Location: Scotland
Trades: 0
Hi, I have drop down navigation on my site (test page :http://www.bozebo.com/index2.php) that tweens in and out. The problem is that the mouseover and mouseout events seem to be called when the mouse moves over elements within the original li that has the events on it. How do I tweek it to stop my navHover function from doing anything in these conditions.
You may want the relevant js file, and of course you can see the markup by viewing the source of my site but I will pull out one of the main parts for you:
Code:
          <li onmouseover="navHover('tutorials',1,this)" 
          onmouseout="navHover('tutorials',0,this)">
            <a href="tutorials">Tutorials</a>

            <ul id="tutorials">
              <li><a href="tutorials/php">PHP</a></li>
              <li><a href="tutorials/javascript">Javascript</a></li>
              <li><a href="tutorials/xhtml">XHTML</a></li>
              <li><a href="tutorials/css">CSS</a></li>
              <li><a href="tutorials/c">C/C++</a></li>

            </ul>
          </li>
Thanks in advance, I have posted on a couple of other forums some days ago with about 50 views and 0 replies >_<

Note: the main site has a simpler version, without the tween thats not working. /index2.php is the test page

Last edited by Bozebo; 06-10-2008 at 12:45 PM..
Bozebo is offline
Reply With Quote
View Public Profile Visit Bozebo's homepage!
 
 
Register now for full access!
Old 06-10-2008, 11:05 AM Re: mouseover and mouseout acting strangely
Skilled Talker

Posts: 62
Name: Tom Wright
Location: Brighton, UK
Trades: 0
Seems to be working fine on your site - what exactly is the problem?
__________________
My site:
Please login or register to view this content. Registration is FREE
tomythius is offline
Reply With Quote
View Public Profile
 
Old 06-10-2008, 12:04 PM Re: mouseover and mouseout acting strangely
Average Talker

Posts: 18
Name: Phil
Location: Scotland
Trades: 0
sorry id given up on being helped (posted ages ago on other forums mainly) and removed the tween stuff, I'll set up another page to test it on (because i dont want the main site to be broken for too long)

Ok heres the url for the test: http://www.bozebo.com/index2.php

Last edited by Bozebo; 06-10-2008 at 12:45 PM..
Bozebo is offline
Reply With Quote
View Public Profile Visit Bozebo's homepage!
 
Old 06-10-2008, 01:34 PM Re: mouseover and mouseout acting strangely
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
The problem is event bubbling.
when someone mouses between LI elements, a mouseout and a mouseover event is triggered.

You just need to it off.
add this to your onmouserover function
Code:
function navHover(nav,type,me,prev,evt){
    var e=(evt)?evt:window.event;
    if (window.event) {
        e.cancelBubble=true;
    } else {
        e.stopPropagation();
    }
do the same to your mouseout function.

Then, you will need to add the event in your HTML event handler
Code:
onmouseover="navHover('tutorials',1,this,event)"
Here's more about accessing the event object.

hope that helps
__________________

Please login or register to view this content. Registration is FREE


Last edited by willcode4beer; 06-10-2008 at 01:36 PM..
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 06-10-2008, 01:49 PM Re: mouseover and mouseout acting strangely
Average Talker

Posts: 18
Name: Phil
Location: Scotland
Trades: 0
edit:

after being confused for a while and forgetting to remove the "prev" argument that i no longer use, i managed to stop firebug complaining about the script, but it is still bubbling. I also tried a few snippets from quirksmode and some other sites i found by googling "javscript bubbling". It still bubbles :S

Last edited by Bozebo; 06-10-2008 at 02:44 PM..
Bozebo is offline
Reply With Quote
View Public Profile Visit Bozebo's homepage!
 
Reply     « Reply to mouseover and mouseout acting strangely
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15519 seconds with 12 queries