Solved

OnMouseUp problem in Javascript

Posted on 2003-11-24
5
733 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

785 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