By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,727 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,727 IT Pros & Developers. It's quick & easy.

AJAX: responsetext versus responsexml when using eventhandlers, IE-problem

P: n/a
Currently I am using a responsexml for an xmlhttprequest. The
information is then processed by javascript : elements are created with
attributes incl events using setAttribute; in other words I create html
with the information in the responsexml. This works fine with firefox
and Opera, but IE doesn't do anything with these events (onclick,
onmouseover, ...) on an image or cell (td) created this way. One
alternative is that I should be able to identify the elements who need
a specific event and then launch a javascript function that adds the
desired event to the tags.
for (var i = 0; i < arrElements.length; i++) {
arrElements[i].onclick = doSomething;
}
The other alternative is that instead of xml I created text (html) on
the serverside and use a responsetext.

I think the second one is the best alternative ?
Or are there other options ?

Pugi!

Dec 4 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Pugi! wrote:
Currently I am using a responsexml for an xmlhttprequest. The
information is then processed by javascript : elements are created with
attributes incl events using setAttribute; in other words I create html
with the information in the responsexml. This works fine with firefox
and Opera, but IE doesn't do anything with these events (onclick,
onmouseover, ...) on an image or cell (td) created this way. One
alternative is that I should be able to identify the elements who need
a specific event and then launch a javascript function that adds the
desired event to the tags.
for (var i = 0; i < arrElements.length; i++) {
arrElements[i].onclick = doSomething;
}
The problem is not with responseText or responseXML, the problem is with
setAttribute in IE scripting HTML. Don't use that, setAttribute in IE is
broken compared to the way it works in other browsers following the W3C
DOM Core specification. You can always use element properties e.g.
element.onclick or element.onmouseover and assign a function directly,
that works cross browser.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 4 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.