Solved

OnMouseUp problem in Javascript

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now