REA_ANDREW
asked on
onmouseup is not firing
hi,
Can anyone tell me why the onmouseup is not firing when I dpress the mouse button, drag it, it will not fire the onmouseup event. here is my code
window.onload=function()
{
//Apply all the events
document.onmousemove = function(e){MouseCo(e);}
for(i=0;i<document.getElem entsByTagN ame('DIV') .length;i+ +)
{
document.getElementsByTagN ame('Div') [i].onmous edown = function(e){MoveElement(e) ;}
document.getElementsByTagN ame('Div') [i].onmous eup = function(){alert("hello"); }
}
}
function MoveElement(e)
{
e = e || window.event;
DT = e.target || e.srcElement;
}
Can anyone tell me why the onmouseup is not firing when I dpress the mouse button, drag it, it will not fire the onmouseup event. here is my code
window.onload=function()
{
//Apply all the events
document.onmousemove = function(e){MouseCo(e);}
for(i=0;i<document.getElem
{
document.getElementsByTagN
document.getElementsByTagN
}
}
function MoveElement(e)
{
e = e || window.event;
DT = e.target || e.srcElement;
}
ASKER
Zvonko, thank you for this. I have amended, and it fires on every mouseout
window.onload=function(){
//Apply all the events
document.onmousemove = function(e){MouseCo(e);}
var div = document.getElementsByTagN ame('DIV') ;
for(i=0;i<div.length;i++) {
div[i].onmousedown = MoveElement;
div[i].onmouseup = MouseUp;
//div[i].onmouseout = function(){this.onmouseup( )};
}
}
function MoveElement(){
DT = this;
}
function MouseUp()
{
alert(this.id);
}
window.onload=function(){
//Apply all the events
document.onmousemove = function(e){MouseCo(e);}
var div = document.getElementsByTagN
for(i=0;i<div.length;i++) {
div[i].onmousedown = MoveElement;
div[i].onmouseup = MouseUp;
//div[i].onmouseout = function(){this.onmouseup(
}
}
function MoveElement(){
DT = this;
}
function MouseUp()
{
alert(this.id);
}
ASKER
how can I stop this? I will be dragging the element, so effectively it will not be a mouseout until they mouseup is fired so should that sort it any way?
Handle the onMouseUp in the document scope.
ASKER
Zvonko thanks thats great, I am posting a second question now on dragging.
Cheers again
Andrew
Cheers again
Andrew
Oh, you are welcome.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry I gorgot to accept. Cheers again
window.onload=function(){
//Apply all the events
document.onmousemove = function(e){MouseCo(e);}
var div = document.getElementsByTagN
for(i=0;i<div.length;i++) {
div[i].onmousedown = MoveElement;
div[i].onmouseup = function(){alert("hello");
div[i].onmouseout = function(){this.onmouseup(
}
}
function MoveElement(){
DT = this;
}