Solved

OnMouseUp problem in Javascript

Posted on 2003-11-24
5
744 Views
Last Modified: 2012-08-14
I am having a problem with the onMouseUp event in javascript. I am writing an internet based mapping application and I want the user to be able to press the mouse button on an image move the mouse somewhere else on the image and then release the mouse button. I have tried this and only the mouseDown event is registering. However I tested this with alerts in the functions for onMouseDown and OnMouseUp and the events register.  If the mouse is pressed and released without moving then umMouseUp works fine.

Here is the source for a test page that fails on the onMouseUp event:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
<script type="text/javascript" language="JavaScript1.2">
   
   function doDown(e) {
      window.status = "Down";
   }
   
   function doUp(e) {
      window.status = "Up";
   }
</script>
</head>
<body>
  <img src="images/temp.jpeg" onMouseDown="doDown(event)" onMouseUp="doUp(event)"/>
</body>
</html>

Here is the source for the test page that works:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
<script type="text/javascript" language="JavaScript1.2">
   
   function doDown(e) {
      alert('Down');
   }
   
   function doUp(e) {
      alert('Up');
   }
</script>
</head>
<body>
  <img src="images/temp.jpeg" onMouseDown="doDown(event)" onMouseUp="doUp(event)"/>
</body>
</html>

I am using IE 6.

Thanks
0
Comment
Question by:StuFletcher
[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
  • 3
  • 2
5 Comments
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9814957
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
<script type="text/javascript" language="JavaScript1.2">
   
   function doDown(e) {
      window.status = "Down";
        im.blur()
        
   }
   
   function doUp(e) {
      window.status = "Up";
      
        
   }
</script>
</head>
<body>
  <img name= "im" src="http://experts-exchange.com/images/logo.gif" onMouseDown="doDown(event);return false" onMouseUp="doUp(event)" onMouseMove="return false">
</body>
</html>

0
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 125 total points
ID: 9814971
sorry left some debug code in there, this is it
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
<script type="text/javascript" language="JavaScript1.2">
   
   function doDown(e) {
      window.status = "Down";       
   }
   
   function doUp(e) {
      window.status = "Up";       
   }
</script>
</head>
<body>
  <img src="http://experts-exchange.com/images/logo.gif" onMouseDown="doDown(event);return false" onMouseUp="doUp(event)" onMouseMove="return false">
</body>
</html>


0
 

Author Comment

by:StuFletcher
ID: 9815023
This works in IE but but still hails in Netcape (7)
0
 

Author Comment

by:StuFletcher
ID: 9815056
That works.

Thanks
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9815164
Thanks, GfW.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
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…

717 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