Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

document.onmouseup

Posted on 2009-07-03
2
Medium Priority
?
655 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

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!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

604 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