views:

64

answers:

4

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. :(

+1  A: 

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

Irwin M. Fletcher
+1  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.

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 ";
                    }
                    }
Shoban
or use a hash instead of if/else
Paul
A: 

Here is an example of how to use javascript and AJAX to estimate the connection speed of a visitor.

Dave Swersky
A: 

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.

MeDiCS