473,413 Members | 1,802 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,413 software developers and data experts.

replacing an onclick event

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
Jul 20 '05 #1
3 8418
John Livermore <jo************@nospm-inginix.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
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.

Jul 20 '05 #3
John Livermore wrote:
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

Jul 20 '05 #4

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

Similar topics

2
by: Prashanth | last post by:
Hi, The application we are developing will be used worldwide by various individuals and organizations . As part of the security restrictions , some of the organization will disable client side...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
17
by: abs | last post by:
My element: <span onclick="alert('test')" id="mySpan">test</span> Let's say that I don't know what is in this span's onclick event. Is it possible to add another action to this element's onclick...
6
by: Cockroach | last post by:
Hello, I have a problem where the onClick of a table row will activates a window.location event, and inside a cell in that row, an image onClick event shows/hides a div. The problem is that...
4
by: RobG | last post by:
I have a function whose parameter is a reference the element that called it: function someFunction(el) { ... } The function is assigned to the onclick event of some elements in the HTML...
5
by: moondaddy | last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below...
5
by: kai | last post by:
Hi, In ASP.NET , what is the difference between OnClick and Click events for a button? Because we have button click event, it can trigger events, why we still need OnClick? Please help. ...
4
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.