Raise onchange event in FireFox

D

daokfella

I need to raise the onchange event and Firefox is giving me some
grief. I hear fireEvent is buggy with some events. Is that true?

My code is simply this:
targetTextbox.fireEvent("onChange");

Works fine in IE but not in FF. Is there a compatible equivalent in FF?
 
P

Peter Michaux

I need to raise the onchange event and Firefox is giving me some
grief. I hear fireEvent is buggy with some events. Is that true?

My code is simply this:
targetTextbox.fireEvent("onChange");

Works fine in IE but not in FF. Is there a compatible equivalent in FF?


Firefox uses the DOM2 synthetic events which doesn't have fireEvent()

Try something like this for Firefox

var e = document.createEvent('HTMLEvents');
e.initEvent('change', false, false);
targetTextbox.dispatchEvent(e);

Flanagan's book covers this stuff well (but not the browser bugs)
<URL: http://jibbering.com/faq/#FAQ3_1>

Yes they synthetic events are buggy. I just had a problem with firing
click events a day ago. Firefox won't actually follow a link in this
situation.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top