November 12, 2006
@ 03:32 PM

So a few weeks ago I wrote a moderately popular embedded video gadget for Windows Live Spaces which allows you to embed videos from popular video sharing sites on your Live.com or Spaces page. Somewhere along the line it seems that this gadget stopped working correctly in Firefox. Specifically click events on the [Preview] and [Save] buttons were not working. After doing some research I came across an article entitled addEventListener attachEvent - Pass parameters to event-function which made me realize that I had to change my code from

btn2.attachEvent("onclick", OnSave);
to
if(window.addEventListener){
     btn2.addEventListener("click", OnSave, true); //Firefox
}else{
     btn2.attachEvent("onclick", OnSave); //MSIE
}
I'm pretty sure that the code used to work at one point in time and from this post on Adam Kinney's blog it does seem that the Atlas framework which is what is used by the Windows Live gadgets platform did write a cross-browser version of attachEvent. I wonder if they took that change out due to negative feedback from developers? I guess this is just another example of why I think trying to standardize gadget widget packaging and then expecting it'll lead to interop between gadget widget platforms is an amusingly naive idea. See the discussion in the comments to my post entitled W3C Working on Widgets 1.0 Spec for more context. :)

UPDATE: Kevin Daly just posted a comment in response to this post which links to a blog post entitled DOM events in the Microsoft AJAX Library. The post confirms that negative developer feedback led to a change in Atlas which breaks event handling in Firefox for any app written against previous versions of the Atlas framework as I speculated above. I've just spent 15 minutes updating and resubmitting all my old gadgets to Windows Live Gallery. If you are a gadget developer you may want to check out your code as well. 

PS: Visit http://carnage4life.spaces.live.com to see what it looks like to embed an MSN SoapBox video in your blog.