Solved

onmouseup is not firing

Posted on 2006-07-18
8
699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

734 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