1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <!DOCTYPE HTML>
<html>
<head>
<title>Ping Testing</title>
<script type="text/javascript">
// fonction appelée sur le ONLOAD du body
function startBody(){
window.startTime = new Date().getTime();
var imgSrc='http://yahoo.com?cacheBuster =' +window.startTime;
var iFrame=document.getElementById('myPingTest');
// ajout événement ONLOAD sur l'IFRAME
iFrame.onload = function(){
var endTime = new Date().getTime();
// initialise le texte à afficher
var sTmp = 'ping time in milliseconds: ';
sTmp += (endTime -window.startTime);
sTmp += '<br>endTime: ' +endTime;
sTmp += '<br>startTime: '+window.startTime;
// supprime événement onload de l'IFRAME
this.onload = function(){};
// affiche le résultat
document.getElementById('div_info').innerHTML = sTmp;
}
// affectation de la page à afficher dans l'IFRAME
iFrame.src = imgSrc;
}
</script>
</head>
<body onload="startBody();">
<div id="div_info"></div>
<iframe id="myPingTest"></iframe>
</body>
</html> |