473,378 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

events and parameters

myObj.onmouseover = someFunction;

How can I set up this so myObj can send parameters to the function ?

Oeyvind

--
http://home.online.no/~oeyvtoft/ToftWeb/


Jul 23 '05 #1
2 1019
On Tue, 12 Oct 2004 21:08:59 +0200, oeyvind toft <oe******@online.no>
wrote:
myObj.onmouseover = someFunction;

How can I set up this so myObj can send parameters to the function ?


An element doesn't "send" anything to its event listeners. The browser
calls listeners directly, using the element to obtain a reference for use
with the this operator.

As for calling a function with arguments, you'll have to introduce an
intermediate function which is called as the listener. It can then call
someFunction, in turn. For example,

myObj.onmouseover = function(e) {
someFunction(
this, // reference to myObj
e || event // event object
);
};

creates an anonymous function which is added as the mouseover listener for
myObj. When called, the this operator will refer to myObj, and on
DOM-compliant browsers, e will be the event object.

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Thanks Michael

Just what I was looking for...

Oeyvind

--
http://home.online.no/~oeyvtoft/ToftWeb/
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: news.microsoft.com | last post by:
In one of my books called "Mastering C#" there is a statement that reads "All event handler delegates must return void and accept two parameters. The first parameter is an object, and it represents...
3
by: michael_vanommeren | last post by:
I have two web applications that I am working with and I am trying to do a Response.Redirect from one to the other. They are setup as separate web applications on the same IIS server. If I go...
3
by: Michael Tissington | last post by:
I'm confused by documentation and examples on using Delegate to create Events for use with COM In some situation I see a parameter list of (sender as Object, e as EventArgs) and other times I...
18
by: **Developer** | last post by:
I always define events with the parameters ByVal sender As Object, ByVal e As EventArgs Even if they are not used. Seems I read someplace that's the thing to do. So I then do:
4
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written...
16
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener...
5
by: Daniel | last post by:
Hey guys When you hook an event (c# 2.0 syntax): myEvent += MyMethodToFire; You need to also unsubscribe it to avoid a resource leak so that the object it is in gets garbage collected like so...
2
by: mswlogo | last post by:
I looked high and low for code to do this and finally found some VB code that did it right. This is a C# flavor of it. public event EventHandler<EventArgsMyEventToBeFired; public void...
11
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
7
by: Siegfried Heintze | last post by:
I'm studying the book "Microsoft Visual Basic.NET Language Reference" and I would like some clarify the difference between events and delegates. On page 156 I see a WinForms example of timer that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.