Click to See Complete Forum and Search --> : Internet connection speed detect


archoverlord
06-11-2003, 02:43 AM
Hi All,

I'm new to the group and wondering if anyone can help. I am building a website for a client and I need a script that will detect internet connection speed when a button is clicked and then display the speed.

I tried a script that came from this forum within Frontpage and the result keeps showinf a speed of "0". Below is the script I tried.

Can anyone post a different script that works better, am I doing something wrong, or can anyone fix the script posted here. Thanks in advance for any help.

<HTML>
<HEAD>
<TITLE>Speed internet connection detection script</TITLE>
<SCRIPT type="text/JavaScript">
//Other scripts on http://www.toutjavascript.com
// Free use if comments remains
var tjs_img;
var tjs_src="tjs.jpg"; // Image to download
var tjs_size=35687; // Size of image
var tjs_delai=100;
var tjs_nb=-1;
var tjs_delai_max=20000; // 20 000 milliseconds
var timer1=0; var timer2=0;
var tjs_fin="";

function Checkkos() {
// Start connection verification
tjs_img=new Image();
timer1=new Date();
timer1=timer1.getTime();
tjs_img.src=tjs_src+"?dummy="+timer1;
tjs_nb=0;
document.countkos.info.value="Verification in progress ";
setTimeout("Timerkos()",tjs_delai);
}
function Timerkos() {
var anim="-"
tjs_nb++;
document.countkos.info.value="Vérification in progress ";

if (tjs_nb*tjs_delai>=tjs_delai_max) { // End of max time
tjs_fin=EvalConnexion(0);
document.countkos.info.value=tjs_fin;
} else {
if (tjs_img.complete) {
timer2=new Date(); timer2=timer2.getTime();
tjs_fin=EvalConnexion(tjs_size/(timer2-timer1));
document.countkos.info.value=tjs_fin;
} else {
setTimeout("Timerkos()",tjs_delai)
}
}
}
function EvalConnexion(kos) {
tjs_nb=-1;
res="";
if (kos==0) {res="Connection not detected";}
if ((kos>0)&&(kos<3)) {res="Modem 28k";}
if ((kos>3)&&(kos<6)) {res="Modem 56k";}
if ((kos>6)&&(kos<100)) {res="High bandwith";}
if (kos>100) {res="You are connectedon LAN"; }
kos=Math.round(kos*10)/10;
return res+" (" + kos +" ko/s)";
}
</SCRIPT>
</HEAD>

<BODY bgcolor="white" >
<FONT face="arial" color="navy" size="2">
<B><BIG><CENTER>Internet Speed Detection</CENTER></BIG></B><BR><BR>
Click on the button to detect your speed connection<BR>
This script only makes an evaluation of the bandwith using the average throughput downloading an image.<BR>
The result is a measure of the downloading speed of an image at a precise moment. Naturally, if other internet activites are performed at the same time, this measure will be wrong.<BR>
<FORM name="countkos">
<INPUT type=text name=info size=40>
<INPUT type=button value="Detect Connection Speed" onClick="Checkkos()">
</FORM>
<BR><BR><BR><BR><BR>
<CENTER><A href="http://www.toutjavascript.com">
<FONT size="1" face="arial" color="#CCCCFF">Tout JavaScript.com</FONT></A></CENTER>
</FONT>
</BODY>
</HTML>
<!-- This Script developped by Olivier Hondermarck webmaster@toutjavascript.com -->
<!-- Other scripts and help at http://www.toutjavascript.com -->

Asch
06-11-2003, 04:44 AM
<html><body>
<% set browObj = Server.CreateObject("cyScape.browserObj")
browObj.SpeedDetector
response.write "Your connection speed is " & browObj.ConnectionSpeed & " kilobits per second"
</body></html>



cheers

asch

archoverlord
06-12-2003, 12:59 AM
Hi Asch,

Thank you so much for your reply. I tried your script in Frontpage, and I can't seem to get it to work. What am I doing wrong? Any ideas? Thank you again.

Khalid Ali
06-12-2003, 07:16 AM
Locate the following lines in the JavaScript section of your code.

var tjs_img;
var tjs_src="tjs.jpg"; // Image to download

this["tjs.jpg"] points to an image that huge in size and being downloaded.you need to replace this with a valid image path thats "huge" few megs at least.
Then your code will work.

Finally, your best bet will always be a server side script,the JS script could not be considered an authentic speed detection .

khaki
06-12-2003, 09:09 AM
hey Asch...

I tried your code exactly (although I had to add the missing closing ASP delimeter) and I got the following error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/speed_detect.asp, line 2

Invalid class string


my line 2 is the same as your line 2.
any idea what is wrong (this code is alien to me... so i wouldn't be able to tell if it looks right or not :rolleyes: )

thanks...
;) k

Asch
06-12-2003, 10:13 AM
archoverload, this is asp...

khaki, hmmm try it like this ....

try it like this :
----------------

<% set bh = Server.CreateObject("cyscape.browserObj")

bh.SetExtProperties "connectiontype, connectionspeed"

bh.GetExtPropertiesEx

conn_type = bh.ConnectionType

conn_bps= bh.ConnectionSpeed

%>
--------------------

this should take the connectiontype & connection speed...


cheers

asch
:D