Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

onmouseup is not firing

Posted on 2006-07-18
8
Medium Priority
?
728 Views
Last Modified: 2006-11-18
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.getElementsByTagName('DIV').length;i++)
        {
             document.getElementsByTagName('Div')[i].onmousedown = function(e){MoveElement(e);}
             document.getElementsByTagName('Div')[i].onmouseup = function(){alert("hello");}

        }
    }
   
    function MoveElement(e)
    {
       e = e || window.event;
          DT = e.target || e.srcElement;
    }
0
Comment
Question by:REA_ANDREW
  • 4
  • 4
8 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 17129826
Check this:

    window.onload=function(){
              //Apply all the events
        document.onmousemove = function(e){MouseCo(e);}
        var div = document.getElementsByTagName('DIV');
        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;
    }  


0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 17129871
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.getElementsByTagName('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);
    }
0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 17129879
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?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 63

Expert Comment

by:Zvonko
ID: 17129921
Handle the onMouseUp in the document scope.

0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 17129944
Zvonko thanks thats great, I am posting a second question now on dragging.

Cheers again

Andrew
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17129962
Oh, you are welcome.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 17133864
It seams we forgotten this one.
Here the changed script:


    window.onload=function(){
              //Apply all the events
        document.onmousemove = function(e){MouseCo(e);}
        document.onmouseup = MouseUp;
        var div = document.getElementsByTagName('DIV');
        for(i=0;i<div.length;i++) {
            div[i].onmousedown = MoveElement;
         }
    }

0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 17137430
Sorry I gorgot to accept. Cheers again
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question