0

是否有可用的网络应用程序可以在指定限制内​​停止任何直接下载?假设应用程序感知到可下载文件的大小高于 1mb,它将自动取消/停止下载。

4

1 回答 1

1

Due to security policy JavaScript only has access to elements within the window it was launched from and the windows that it has launched.

Download dialogues are launched by the browser itself not by JavaScript. The browser could choose to not launch a download dialogue and launch a rendering window instead. For ex. PDFs in firefox are forced as a download while in chrome they are displayed to the user you. If you had a browser plugin in firefox for PDF rendering you wouldn't get the download dialogue there either.

You can cut the download to whatever length you want it from the server side. Write a script that reads the contents of the file to be transferred, transfer it in chunks and stop when the sum of the sizes of the chunks is greater or equal to the desired size.

于 2012-12-20T07:50:54.870 回答