Re: A ping program in javascript?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: A ping program in javascript?

From: Csaba Gabor <Csaba@z6.com>
Date: Wed Jul 20 2005 - 20:48:06 CEST

Here is a revised way of pinging yahoo using javascript and iframes
that seems to work with Firefox (but Not IE 6) 1.0+ (Deer Park Alpha 1
rv.1.8b2 dated 20 Jun 2005). Pretty nifty that FF has an onload in the
<IFRAME ...> element.
Regarding my prior (post) example... Evidently .getMilliseconds is not
the way to go, despite Danny Goodman saying that it is equivalent to
.getTime

<html><head><title>Ping Testing</title>
<script type='text/javascript'>
function pingTime() {
    var endTime=new Date();
    alert('ping time in milliseconds: '+
          (endTime.getTime()-window.startTime)
          +"\nendTime: "+endTime.getTime()
          +"\nstartTime: "+window.startTime)
}
</script>
</head>
<body onload="alert('body loaded');
              var startTime=new Date();
              window.startTime=startTime.getTime()
              var imgSrc='http://yahoo.com'+
                         '?cacheBuster='+Math.random();
              var iFrame=document.getElementById('myPingTest');
              iFrame.onload=pingTime;
              iFrame.src=imgSrc">
<IFRAME id=myPingTest>
</IFRAME>
</body>
</html>

Csaba Gabor from Vienna
Received on Tue Oct 18 02:58:52 2005