?
Solved

document.onmouseup

Posted on 2009-07-03
2
Medium Priority
?
650 Views
Last Modified: 2013-11-19
Hi

I am defining an event using javascript

like

document.onmouseup = mousehandler;

but now I want to define another event on onmouseup. How can I do that
0
Comment
Question by:KaranGupta
[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
2 Comments
 
LVL 5

Accepted Solution

by:
Opalelement earned 2000 total points
ID: 24772580
Snippet:)
document.onmouseup = runMouseEvents;
 
function runMouseEvents()
{
    mousehandler();
    anotherEvent();
}
 
function mousehandler()
{
    // code
}
 
function anotherEvent()
{
    // other event code
}

Open in new window

0
 
LVL 3

Expert Comment

by:laneway
ID: 24773625
You can also define an unlimited number of events like this:
<input id="btn" type="button" value="I have two events!" />
<script>
// define event functions
function event_one() { alert('one!'); }
function event_two() { alert('two!'); }
// get the button element that will trigger these events
var btn = document.getElementById('btn');
// attach the two events for internet explorer
if (btn.attachEvent) { 
  btn.attachEvent('onclick',event_one); 
  btn.attachEvent('onclick',event_two); 
}
// attach the two events for all other browsers
if (btn.addEventListener) { 
  btn.addEventListener('click',event_one,false); 
  btn.addEventListener('click',event_two,false); 
}
</script>

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

741 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