[thelist] [JavaScript] IE: attaching events to generated content

Paul Bennett Paul.Bennett at wcc.govt.nz
Thu Jan 18 14:16:18 CST 2007

Hi Matt,

The old createElement() code has been superceded by changes from yesterday, but here's a sketch of the logic I was using:

Check if this page needs the element to be shown (global var set in script in head of html page)  

If yes, get parent element (containing div) by id
Create new 'a' element
Add attributes to new 'a' element
Create new 'img' element
Add attributes to new 'img' element
Append img element to parent a element
Append a element to parent div

Attach events to new 'img' and 'a' elements

As I stated, this worked without error in Firefox and Opera, but the events didn't attach (again without error...) in IE.

I'm guessing that this type of thing should work fine in IE?
If so then you're probably right - there must have been a logic error in my script.


More information about the thelist mailing list