473,543 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why IE doesn't detect events on dinamically created elements?

Hello I am creating div elements on the fly with javascript:
....
this.closeButto n = document.create Element('div');
this.closeButto n.setAttribute( 'id', this.name+ 'Close');
this.closeButto n.setAttribute( 'class', 'closeButton');
this.closeButto n.setAttribute( 'onclick', "anyFunction()" );
this.closeButto n.className="cl oseButton"
me.windowContro ls.appendChild( me.closeButton) ;
....
My first problem was that elements didn't reflect the class attributes
in IE although in Firefox worked fine. I solved this with:
"this.closeButt on.className="c loseButton"".

But now I have the same problem with the "onclick" event. In Firefox
works OK but IE doesnt detect the click although I can see that the
"outputHTML " is OK.

Does anybody know how to solve this?

Apr 3 '06 #1
2 1194
On 03/04/2006 17:40, eq******@gmail. com wrote:

[snip]
My first problem was that elements didn't reflect the class
attributes in IE although in Firefox worked fine. I solved this with:
"this.closeButt on.className="c loseButton"".


Yes, that's because IE's implementation of the setAttribute method is
broken. Don't use it.

this.closeButto n.id = this.name + 'Close';
this.closeButto n.className = 'closeButton';
this.closeButto n.onclick = anyFunction;

Or:

this.closeButto n.onclick = function() {
/* ... */
};

Also, please don't use tabs on Usenet. Replace them with spaces -
preferably no more than four per level.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Apr 3 '06 #2
Thank you very much. I´ll remember about the tabs too.
Greetings from Barcelona.

Carlos

Apr 4 '06 #3

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

Similar topics

2
1459
by: Daniel | last post by:
Hello!!! I'm creating controls dinamically in ASP.NET using VB. The problem is that i don't know how to catch the event of each button that i've create (the buttons are created dinamically). Any ideas?? Thanks!!!
7
6530
by: Lars-Erik Aabech | last post by:
Hi! I've got problems with serializing my collections of business objects. The objects themselves serialize fine, but the collections fail. I've got the following structure: Base collection class: Derives MarshalByValueComponent Implements ICollection, IList and ISerializable Explicitly implements the IList methods as private members,...
10
4928
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading. My problem is that I must not be doing it right because only some of the stuff works as would be expected. I'll post what exactly is happening, then...
1
1180
by: Troy | last post by:
I have a usercontrol placed inside a container control on the main form. The user control has an image button plus several text boxes. When I click the button, some sort of activity occurs but the click event in the code behind is never touched. Incidently, the PreRender event with the user control successfully loads dynamic data from a SQL...
4
1327
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I can create the label and the webcontrol dinamically with no errors, but only the Label appear in the panel when the page is shown in the client...
3
2672
by: valerio | last post by:
Hello all I would like to dinamically allocate an array of array of structures. To explain this: struct file{ char* fileName,int inode) myfiles; struct file{ char* fileName,int inode) mydirs; but I would like to do it dinamically with linked list. I am able to do it for myfiles, but not with mydirs. Pseudo-code is ok.
2
1968
by: JonBosker | last post by:
I have a form developed in ASP.net and as such all of my controls are server controls and do not have access to onchange events. What I need is a javascript program to detect changes. Here is my idea... when the page loads the program cycles through all of the objects in the form and saves their values into a variable. Then, when the user...
7
2318
by: mavigozler | last post by:
IE7 does not appear to set an event on contained text inside SPAN elements whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML recommendation. Firefox appears to conform. Is that so?
2
1829
by: =?Utf-8?B?Sm9yZ2UgUmliZWlybw==?= | last post by:
hello Inside a usercontrol i create a webcontrol button. I then render it onto a string on the usercontrol to built my UI I need to get access to that control Click event. To do so i try to bind the button's Click event to a procedure but it never fires... When the client is viewing the page that has the control in it, and click the...
0
7411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7354
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5888
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5282
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3394
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1824
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 we have to send another system
1
978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
643
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.