Index ¦ Archives ¦ Atom

IE perform action after File Input Change Event

Normally IE won't register that a file input has changed unless the file input loses focus. So, in order to accomplish this, just add a click event to the file input event that sets the focus to another input (submit button will work) after the click. If you do this in a setTimeout call then IE will attempt this call immediately after the File Dialog is dismissed causing a blur event which will then trigger your "change" handler.

Put this in your click handler:

setTimeout("document.getElementById('submit-button').focus()", 0);

I'm always amazed how often a setTimeout has gotten me out of problems with IE javascript.

© Steve Spigarelli. Built using Pelican. Theme by Giulio Fidente on github.