Javascript-created elements won't trigger in IE

J

joeakabloo

OK I made a better example for this issue:

http://sandbox.lesshype.com/home.php

2 buttons, one created prior to sending the page, and one created on
the fly by javascript DOM method. Both have an alert onclick action
applied.

The javascript one will not trigger in IE under and circumstances. Any
thoughts?

Thanks in advance
Joe
 
M

Michael Winter

On 24/04/2006 13:20, (e-mail address removed) wrote:

[snip]
http://sandbox.lesshype.com/home.php
[snip]

The javascript one will not trigger in IE under and circumstances. Any
thoughts?

If you had looked through the archives of this group, you would have
understood why.

Do not use the setAttribute method to add event listeners. Use the
intrinsic event properties, instead. In fact, avoiding the setAttribute
method is a good idea, in general, as IE doesn't implement it well.


Notes about that document:

- Serving XHTML as HTML is pointless at best. Serving XHTML
Transitional really /is/ a waste of time; not even new HTML
should be written to the Transitional DTD. If you must (which
is unlikely to be the case), don't include the XML prolog as
it will throw IE into Quirks mode.
- The Content-Type meta element is redundant. Your server is
sending a Content-Type header, and that will take precedence.
- Comment declarations in script and style element content has
been unnecessary in HTML for years. It is catastrophic in
XHTML: the comment will be taken literally and the content
will be ignored.
- If I read your intentions right, you want to use the
XMLHttpRequest object to load both content and navigation. If
this is for the Web, that is a /terrible/ idea.
If you want to load content dynamically, use a server-side
language. You have PHP, so put it to use. Relying on scripting
to provide content is bad enough, but a feature like the
XMLHttpRequest object is so much worse.

Mike
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top