Sunday, August 14, 2011

Cancel file upload to iframe

This was a lot more difficult to find that I thought it would be so I'll capture it here in the hopes that is helps us (or anyone else) next time it is needed.

Situation: We use a hidden iframe as the target of the form that we are doing a file upload from. The contribution to this post by Steve Wasiura is what finally got me unstuck.

$('button#cancelUpload').click(function() {
    var amfIfrm = document.getElementById('amf_ifr');
    if($.browser.msie) { // Internet Explorer
      amfIfrm.contentWindow.document.execCommand('Stop');
    } else { // Other browsers
      amfIfrm.contentWindow.stop();
    }
  });

No comments:

Post a Comment