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 -->
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 -->