replacing an onclick event

J

John Livermore

From javascript in IE, I have a need to hijack the onclick event for
an element and replace it dynamically with my own.

I have tried the following...

control.onclick = 'myHandler();';

but this doesn't seem to do the trick. How do I go about doing this?

Thanks,
John
 
L

Lee

John said:
From javascript in IE, I have a need to hijack the onclick event for
an element and replace it dynamically with my own.

I have tried the following...

control.onclick = 'myHandler();';

but this doesn't seem to do the trick. How do I go about doing this?

control.onclick=myHandler;

You're not replacing an event, you're replacing an event handler.
Event handlers are functions, not strings.
 
L

Lasse Reichstein Nielsen

John Livermore said:
From javascript in IE, I have a need to hijack the onclick event for
an element and replace it dynamically with my own.
I have tried the following...
control.onclick = 'myHandler();';

but this doesn't seem to do the trick. How do I go about doing this?

You have to assign a function.
Try
control.onclick = myHandler;

/L
 
P

Phil N

John said:
From javascript in IE, I have a need to hijack the onclick event for
an element and replace it dynamically with my own.

I have tried the following...

control.onclick = 'myHandler();';

but this doesn't seem to do the trick. How do I go about doing this?

Thanks,
John

captureEvents ???

--

--
Phil Newcombe - philn?telus?net
http://www3.telus.net/bikim

Netscape/Gecko/Mozilla - standards conformance and cooperation
Internet Explorer - standards obfuscation and divergence
Linux += 30,000/Germany + 80,000/Spain + tomorrow
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,566
Members
47,202
Latest member
misc.

Latest Threads

Top