473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do I invoke onmoueout handler when leaving group of children

I'm adding a number of <div> children to the <span> element below. I want to
have 'mouseOut' invoked only when I leave the box surrounding the <span>
(and therefore all of its children).

The code below invokes mouseOut both when I enter the box and when I leave
it.

I've been stuck on this for a couple of days and would appreciate any help.

Thanks, Ron.

<td onmouseout='mouseOut()'>
<span id='proxyList' onmouseout='window.event.cancelBubble=true'
style='border:1px
solid #ddeeff padding:5px;width:100%;background-color:white'>
</span>
</td>


Jul 23 '05 #1
4 1010
Ron Brennan wrote:
I'm adding a number of <div> children to the <span> element below.
Is this legal HTML?
I want to
have 'mouseOut' invoked only when I leave the box surrounding the <span>
(and therefore all of its children).
You cannot really control when the mouseout event will fire, but you can
check whether the "related" target (the target where the event is
"going to" or "coming from") is contained in the target, and trigger the
mouseout code accordingly.

---
<div id="foo"><span>Hello, </span><span>World</span></div>

<script type="text/javascript">
function contains(container, containee){
if(container.contains) return container.contains(containee);
else if(typeof containee.parentNode!="undefined"){
while(containee && containee!=container)
containee=containee.parentNode;
return !!containee;
}
return false;
}

if(document.getElementById){
document.getElementById("foo").onmouseout=function (evt){
var rel;

evt=evt||window.event;
rel=evt.relatedTarget||evt.toElement;

if(!contains(this, rel)){
window.status="Do something" + new Date().getTime();
} else {
window.status="Do nothing" + new Date().getTime();
}
};
}
</script>
---
The code below invokes mouseOut both when I enter the box and when I leave
it.


This is because the browser considers that before entering an element it
has to leave another - there's no inner-outer-element sort of reasoning;
adding mouseover handlers would show you the full process.

Try searching the archives at http://groups.google.com/ for
"fromElement", "contains", "toElement", "relatedTarget", "mouseenter",
"mouseleave".
HTH
Yep.
Jul 23 '05 #2
On Sat, 19 Jun 2004 11:12:54 +0200, Yann-Erwan Perio wrote:
I'm adding a number of <div> children to the <span> element below.


Is this legal HTML?


'legal'? Don't know.
It is not valid according to the
W3C recommendation though.
<http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-DIV>

'div' is a block level element that might
contain any number of 'span' (inline)
elements, or other divs..

The behaviour of divs/spans could be
reversed in the CSS, not that that makes
any sense either. Especially since the
presentation should degrade gracefully to the
correct (if ugly) structure and the content.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #3

Yep's (professional) response accomplished exactly what I described and
wanted to do.
Jul 23 '05 #4
Yann-Erwan Perio wrote:
Ron Brennan wrote:
I'm adding a number of <div> children to the <span> element below.


Is this legal HTML?


It is invalid HTML. SPAN is an inline-level element
and must not contain block-level elements like DIV.
It may contain other inline-level elements and text
nodes only.
PointedEars
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... ...
10
by: Abel | last post by:
I have this code string theClassName = "Rules.FillListBox.FillListBox" + theType + ", Rules" Type theClass = Type.GetType(theClassName) Object o = Activator.CreateInstance(theClass) object...
3
by: David Logan | last post by:
I have an application using sockets, and it uses the asynchronous method for receiving (and others, but receiving is the basic problem.) In short, I want: class someClass: Form {...
5
by: RickDee | last post by:
Please help, anybody. I am trying to write a program so that it can launch an exe file ( which is also genereated in C# ) and then simulate the button clicking and invoke the methods inside the...
1
by: Marius Groenendijk | last post by:
Dear Group, I have a MDI with children which may be editing data. If a MDI child closes its Closing handler asks a question 'exit w/out saving?'. On closing the MDI its pops a question 'Exit...
7
by: Jeff Stewart | last post by:
I need a thread to run a subroutine which updates my main form's progress bar. I've properly marshaled all UI updates to the main UI thread, and after the main thread starts the worker thread, it...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
11
by: cindy | last post by:
I have a form, has javascript registered so a modal pops up. Button click will close form. Now I need to do an update with modal form data before it closes. I can put a second button and register...
2
by: Pucca | last post by:
I'm building a treeview and a list view. I need to know when I reached the end of the tree nodes, which means that node or directory entry has no children. Is there a property or method in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.