下载网站估算器

发布于 2024-08-22 02:30:47 字数 142 浏览 3 评论 0原文

我想计算/估计下载文件所需的时间。有什么方法可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请爱~陌生人 2024-08-29 02:30:47

对此没有明确的答案,因为速度可能会有所不同,并且下载开始后速度可能会有所不同。

微软网站有类似的东西你正在寻找。 这里有一个示例。< /a>.但这也有一个大概的时间,而且永远不会是完美的。以下是页面中的代码。它们只是根据我们手动选择的连接速度显示大约时间。

function getTime(selection) {
                    var opt = selection.options[selection.selectedIndex].value;
                    var obj = document.getElementById("displayTime");

                    if (opt == "du56") {
                    obj.innerHTML = " 7 min ";

                    } else if (opt == "dsl256") {
                    obj.innerHTML = " 2 min ";

                    } else if (opt == "dsl768") {
                    obj.innerHTML = " 1 min ";

                    } else if (opt == "t1") {
                    obj.innerHTML = " 1 min ";
                    }
                    }

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.

function getTime(selection) {
                    var opt = selection.options[selection.selectedIndex].value;
                    var obj = document.getElementById("displayTime");

                    if (opt == "du56") {
                    obj.innerHTML = " 7 min ";

                    } else if (opt == "dsl256") {
                    obj.innerHTML = " 2 min ";

                    } else if (opt == "dsl768") {
                    obj.innerHTML = " 1 min ";

                    } else if (opt == "t1") {
                    obj.innerHTML = " 1 min ";
                    }
                    }
停顿的约定 2024-08-29 02:30:47

这是一个网站,可让您根据您的连接类型计算下载时间。您也可以在此处查看 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

高冷爸爸 2024-08-29 02:30:47

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文