473,395 Members | 1,629 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,395 software developers and data experts.

Event canceling...

The goal is the following:

1) On a mouseover, create & show a div;
2) If the user hovers over the div, keep it visible, otherwise remove
and destroy.

I haven't been able to find examples, so I came up with this idea:

1) On a mouseover, create & show the div inside a containing div. Set
this created div as "currently visible";
2) On mouseover of the containing div, hide the "currently visible"
div;
EXCEPT
3) Cancel the event bubble if the mouse happens to hover over the
"currently visible" div.

Of course, what I have so far isn't working, and I don't even know if
I'm solving the problem in any efficient manner. Any help would be much
appreciated!

--Brent
--------------------------------------------------
var cv = null; //curr visible

function ad(e,id) { //create and show div in 1.5 seconds
var l = e.clientX;
var t = e.clientY;
var i = document.getElementById('containerDiv');
var y = document.createElement('div');
y.id = 'a'+id;
y.onmouseover = 'javascript:kv(event)'; //<---this line doesn't seem
to work!
y.innerHTML = '<a href="javascript:delLink('+id+')">Delete</a>';
y.style.height = '100px';
y.style.width = '100px';
y.style.border='1px solid #c3c3c3';
y.style.position='absolute';
y.style.top = t +'px';
y.style.left = l +'px';
e.cancelBubble = true;

function func()
{
i.appendChild(y);
cv = y;
}
window.setTimeout(func, 1500);
}

function rd() {//remove div
var d = document.getElementById('linkdiv');
function func()
{
if(cv != null)
{
d.removeChild(cv);
cv=null;
}
//d.removeChild(document.getElementById('man'+id));
}
window.setTimeout(func, 1500);
}

function kv(e) //keep visible
{
e.cancelBubble = true;
}

May 22 '06 #1
1 1206
wr********@gmail.com said the following on 5/22/2006 1:51 AM:
The goal is the following:

1) On a mouseover, create & show a div;
2) If the user hovers over the div, keep it visible, otherwise remove
and destroy.


Why the need to destroy it? If the user mouses over again, you have to
re-create and destroy it again. Simply hide/show it.

Or, is this an academic exercise?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 22 '06 #2

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

Similar topics

5
by: Maxine G | last post by:
I have two forms, a menu and a data entry form. The entry form is bound to a query against linked SQL server tables. In the deactivate event, I have some code which asks the user if they want to...
9
by: Susan Bricker | last post by:
I am currently using the OnDirty event of a Form to detect whether any fields have been modified. I set a boolean variable. Then, if the Close button is clicked before the Save button, I can put...
1
by: AT | last post by:
I have an aspx page with this code behind Public Class WebForm1 Inherits Class1 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '...
16
by: Al Santino | last post by:
Hi, It appears displaying a messagebox in a validating event will cancel the subsequent event. In the program below, button 2's click event doesn't fire if you open a dialog box in button 1's...
4
by: PW | last post by:
Hi, I want to add code to check if the user wants to save the record (fields are unbound) when they press the form's close (X) button. Is it possible to return the user to the form if there...
6
by: MLH | last post by:
I have a form, frmUSPSReturnReceipts, with a control named NotExpectingGreenTickets. The control's Exit event procedure follows: Private Sub NotExpectingGreenTickets_Exit(Cancel As Integer) If...
2
by: JohnR | last post by:
I know about AddHandler and RemoveHandler, but my requirement is a little more complex. I pass a form to a routine. In that routine I must scan each control, and for each "button" control I find,...
0
by: rcarmich | last post by:
I am having an issue canceling a beginReceive call on a timeout. For example, the following function: public int ReadBytes(Socket theSock, byte arr, int startByte, int length, int timeout) {...
0
by: diff | last post by:
I am having trouble preventing a bound source from updating using event-driven validation. There is a very nice article on MSDN explaining this;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.