Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Event canceling...

Reply
Thread Tools

Event canceling...

 
 
writebrent@gmail.com
Guest
Posts: n/a
 
      05-22-2006
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;
}

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      05-22-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Catching a RequiredFiled Validator event in PageLoad or some other event? Lars Netzel ASP .Net 3 07-22-2004 10:48 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
PreRender Event occurs immediatley after Load event =?Utf-8?B?QWxpcmV6YSBaaWFp?= ASP .Net 1 02-09-2004 10:19 AM
Event On Form From Control Event Dave Wurtz ASP .Net 1 12-09-2003 10:37 PM



Advertisments