I can't think of any generic way that it can be done while avoiding adding support for DOM events.