Phreak Posted May 9, 2003 Posted May 9, 2003 Anyone have any idea how you could detect the connection speed of someone viewing your website? AND calculate the estimated time for a download of a certain file. I thought about trying to ping the ip of the connection and do some math, but that's not a correct way to configure bandwidth. Anyone have any ideas about how to accomplish this? Quote If it works... don't worry, I'll fix it.
*Gurus* divil Posted May 9, 2003 *Gurus* Posted May 9, 2003 Nice idea, but I think firewall and proxy problems would make any such attempt not worth it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Phreak Posted May 9, 2003 Author Posted May 9, 2003 I found this Javascript function and it seems to be working. If anybody finds any flaws in it, PLEASE let me know. I can't seem to find any. <html> <head><!-- Do not cache this page --> <meta http-equiv="Pragma" content="no-cache"> <title>Speed Test - Graphics</title> </head> <!-- This function computes the time it took to load up the page --> <script language="JavaScript"> function results() { var time2, timed, thruput, title time2 = new Date() //Calc difference and convert from msec to sec. timed = (time2.getTime()-time1.getTime()) / 1000 /* Calc Kbps using formula: [throughput (in Kbps)] = [file size (in bytes)] * 8 / [elapsed time] / 1000 */ thruput = (225455 * 8) / timed / 1000 document.open() // Stops the page from loading. document.close() // Turns off the hourglass. title = "Speed Test - Graphics" document.write("<html><meta http-equiv='Pragma' content='no-cache'><title>" + title + "</title>") document.write("<body bgcolor='#FFFFFF'>") document.write("<h1 align='center'>" + title + "</h1>") document.write("<font size='4'><center>Loaded 225,455 bytes in " + (timed) + " seconds.</center>") document.write("<center>Your throughput is <B>" + Math.round(thruput) + "</B> Kbps.</center></font>") document.write("<hr noshade>") document.write("<p align='center'><a href='" + document.location + "'>Run Test Again</a></p>") document.write("</html>") } </script> <body onload="results()" bgcolor="#FFFFFF"> <!-- Start timer --> <script language="JavaScript"> time1 = new Date() </script> <p align="center"><big><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Speed Test - Graphics</b></font></big></p> <p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Loading 225,455 bytes (compressed JPEG)... please wait.</font></b></p> <hr noshade> <font face="Arial, Helvetica, sans-serif"> <!-- defeat the browsers image cache by appending a timestamp --> <script language="JavaScript"> imgLocation = "images/test.jpg" + "?" + time1.getTime() document.write("<p align='center'><img src='" + imgLocation + "' align='center' width='256' height='256' alt='Loading 225,455 bytes...'></p>") </script> </font> <hr noshade> </body> </html> Quote If it works... don't worry, I'll fix it.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.