Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Event canceling... (http://www.velocityreviews.com/forums/t924888-event-canceling.html)

writebrent@gmail.com 05-22-2006 05:51 AM

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;
}


Randy Webb 05-22-2006 06:01 AM

Re: Event canceling...
 
writebrent@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/


All times are GMT. The time now is 09:07 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57