I don't recall if this has been discussed before, but I found myself in need of a cross browser way to fire a native event (In particular "onchange") on a HTMLElement. After some sporadic research, I have put together the following function: /** * Fires a native HTMLEvent on an HTMLElement * element : HTMLElement The target element * eventName : string The name of the event to raise. Should be all lowercase and include the trailing 'on'. */ fireNativeEvent = function(element, eventName) { if (element.fireEvent) { // MSIE element.fireEvent(eventName); } else { // W3C var event = document.createEvent("HTMLEvents"); event.initEvent(eventName.replace(/^on/, ""), true, true); element.dispatchEvent(event); } }
I tested this with an onchange-event for a input=text in IE7, FX2, and O9. Maybe it could be integrated into the signal() function, so one could simply do signal(element, "onchange")? -- troels --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---