?
Solved

OnMouseUp problem in Javascript

Posted on 2003-11-24
5
Medium Priority
?
753 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 500 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

Technology Partners: 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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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

770 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