下载网站估算器
我想计算/估计下载文件所需的时间。有什么方法可以使用 JavaScipt 或其他东西来实现这一点吗? 可以达到什么水平的准确度? (+evs / -evs)
我尝试过下载小图像,然后执行数学运算以获得所需的带宽和时间。但事实证明,情况并不那么好。 :(
I would like to calculate/estimate the amount of time file will take for download. Is there any way using which this can be achieved using JavaScipt or something else?
What level of accuricy can be achieved ? (+evs / -evs )
I have tries this by downloading small image and then performing maths to get the bandwidth and time needed. But that turned out not to be so good. :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对此没有明确的答案,因为速度可能会有所不同,并且下载开始后速度可能会有所不同。
微软网站有类似的东西你正在寻找。 这里有一个示例。< /a>.但这也有一个大概的时间,而且永远不会是完美的。以下是页面中的代码。它们只是根据我们手动选择的连接速度显示大约时间。
There is no definite answer for this as it can vary between speeds and speed can vary as soon as the download starts.
Microsoft website has a similar kind of thing which you are looking for. An example is here.. But that too has a approximate time and will never be perfect. Below is the code from the page. They just show an approximate time based on the connection speed we manually select.
这是一个网站,可让您根据您的连接类型计算下载时间。您也可以在此处查看 java 脚本。
http://www.onlineconversion.com/downloadspeed.htm
这当然要求结束用户知道他们拥有什么类型的连接。
这是一个向您展示如何使用 javascript 检测连接类型
http://ditio.net/2008/08/06/detect-connection-speed-with-javascript/
这两个实际上只是估计,但我不知道我有什么下载工具看到的很准确,只是因素太多
Here is a site that lets you calculate the download time based on your connection type. You can view the java script here as well.
http://www.onlineconversion.com/downloadspeed.htm
This of course requires that the end user know what type of connection that they have.
Here is a site that shows you how to use javascript to detect connection types
http://ditio.net/2008/08/06/detect-connection-speed-with-javascript/
Both of these are really just estimates, but I don't know that any download tool that I have seen is exact, there are just too many factors
JavaScript 本身无法知道实际传输了多少 POST 或 XMLHTTPRequest 数据。您可以将 JavaScript 与某种服务器端脚本结合使用(正如许多文件托管站点所做的那样),或者构建 Flash 或 Java 上传器。无论哪种方式,您都无法使用纯 JavaScript 准确地完成此操作。
JavaScript, by itself, doesn't have a way to know how much of a POST or XMLHTTPRequest data has actually been transferred. You could use JavaScript coupled with some sort of server-side scripting (as lots of file-hosting sites do), or build a Flash or Java uploader. Either way, you can't do it accurately with pure JavaScript.