Solved

document.onmouseup

Posted on 2009-07-03
2
645 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 500 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

Industry Leaders: 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 Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

705 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