- From: Jim Ley <jim@jibbering.com>
- Date: Tue, 14 Mar 2006 20:16:18 -0000
- To: "\"Web APIs WG \(public\)\"" <public-webapi@w3.org>
"Maciej Stachowiak" <mjs@apple.com> >> Inconsistency is very annoying for the author. > > 1) Safari, Firefox, Opera and IE all have live event listener attributes. IE does not, it only has live properties ie onclick=function() {} works but setAttribute("onclick","alert(1)"); does not result in an alert if you click it. (you can pass a function as the 2nd parameter to setAttribute, but that would be non-conformant, and doesn't work in any other UA) There are further differences, in Opera 8.5/9 and Mozilla: alert(document.body.getAttribute('onclick')); document.body.onclick=function() { chicken() } alert(document.body.getAttribute('onclick')); the getAttribute doesn't reflect the change to the onclick property - but does result in the function being called not the attribute, so the UA's are not simply re-executing the attribute at each point in time, so it's not clear why changing the attribute should have an effect. In firefox 1.5: document.body.onclick=function() { alert(2) } document.body.setAttribute('onclick','alert(3)'); results in both 2 and 3 being alerted. So I don't really agree that there is great consistency in setAttribute and event properties, none of the 3 I've tested here interopate at all - given that I would prefer to say only the one that is universal - the property, is the one that should be used and setAttribute should not, as that provides maximum compatibilty. Cheers, Jim. crappy test case at http://jibbering.com/2006/3/scriptTest.html you'll need to view source.
Received on Tuesday, 14 March 2006 20:17:21 UTC