473,499 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

assigning to onmousedown a function that accepts an argument

I'm creating a HTML element dynamically using javascript and I want to
assign a handler to its onmousedown.
var myNewElem;
....
myNewElem = function() { do_somthing(); }

The handler needs to be able to process the event argument that is
passed to it. i.e. the actual handler should look like this:
function mouseDownHandler(e)
{
// use e.event_details_etc
}

How do I do this?
myNewElem = function(e) { alert(e); }
doesn't seem to work. it just says 'e' is undefined.

May 6 '07 #1
3 1735
On May 6, 6:54 am, Assaf Lavie <assafla...@gmail.comwrote:
I'm creating a HTML element dynamically using javascript and I want to
assign a handler to its onmousedown.
var myNewElem;
...
myNewElem = function() { do_somthing(); }
myelem.onmousedown=function(e){doSomething(e||even t)}

function doSomething(e){
alert(e)
}

works in ie,ff,op

May 6 '07 #2
On May 6, 4:40 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
On May 6, 6:54 am, Assaf Lavie <assafla...@gmail.comwrote:
I'm creating a HTML element dynamically using javascript and I want to
assign a handler to its onmousedown.
var myNewElem;
...
myNewElem = function() { do_somthing(); }

myelem.onmousedown=function(e){doSomething(e||even t)}

function doSomething(e){
alert(e)

}

works in ie,ff,op
Tried it and the argument is always undefined (e or event)...

May 8 '07 #3
On May 8, 2:50 am, Assaf Lavie <assafla...@gmail.comwrote:
I'm creating a HTML element dynamically using javascript and I want to
assign a handler to its onmousedown.
....
Tried it and the argument is always undefined (e or event)...
Try:
[element].onmousedown=x

function x(e){
alert((e||event).clientX)
}

May 8 '07 #4

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

Similar topics

6
4717
by: RC | last post by:
<a href="#" onmousedown="callMyFunction()">Press the mouse button</a> What I expect is when I or an user move mouse pointer over that link, and press the mouse button. Then will...
3
6810
by: atn2002 | last post by:
I'm trying to create a control which when the mouse button gets pressed on one div an absolute positioned div pops up in place of the cursor. From there the cursor should interact with the dialog...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.