views:

1440

answers:

3

I am using the dojo.io.iframe.send method to send a file to my server. I want to provide a way that the user can cancel the send once it is in progress, in case it is taking too long or the user realizes she sent the wrong file.

I can't figure a way to do this. I could use a timeout to terminate the send if it is taking a long time (that is, the server does not respond quickly), but that is not what I want. I want to terminate any time the user makes a gesture (such as clicking a "Cancel" button.

Thanks!

A: 
Eugene Lazutkin
A: 

Hi i realize this is a rather late reply so i hope you or someone who stumbled here through google will have some use for this.

It is possible to cancel the file upload in the iFrame, in Firefox you can call the method window.stop() on the iFrame. IE however doesn't have this method but comes with the execCommand("Stop") however since manually pressing stop doesn't even work the scripted stop wont either.

My first attempts involved setting the location of the iFrame to about:blank to no avail sadly. However browsing to a source that has a body will cancel the iFrame POST!

Martijn Laarman
A: 

What a friend did was simply reloading the webpage when the cancel button was preseed (I think by calling document.location.refresh function). There IS also a way of monitoring the progress o an upload (having a progress bar), but it's server dependent (in the case I saw, it was an apache module, then you would poll for the progress on a specified link and the server would return the progress).

Lonecat