• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 760
  • Last Modified:

OnMouseUp problem in Javascript

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
StuFletcher
Asked:
StuFletcher
  • 3
  • 2
1 Solution
 
GwynforWebCommented:
<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
 
GwynforWebCommented:
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
 
StuFletcherAuthor Commented:
This works in IE but but still hails in Netcape (7)
0
 
StuFletcherAuthor Commented:
That works.

Thanks
0
 
GwynforWebCommented:
Thanks, GfW.
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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now