Well I put this ajax routine together using zXml which can be found here
http://www.nczonline.net/downloads/
It is really just a cross-browser library the smooths over browser differences for ajax type functions.
Anyway, I put this together but I think it is taking the html from the cache so IE always gives me 0 seconds. I don't really like my solution but I don't plan on working any more at it so figured I'd post it anyway on the off chance that it gets you started.
<html>
<head>
<title>Find Latency to Load This Page</title>
<script type="text/javascript" src="js/zxml.src.js"></script>
<script type="text/javascript">
var tStart = null;
var tStop = null;
function getTimeElapse() {
if (!tStart || !tStop) {
return("Error retrieving time.");
}
t = tStop.getMilliseconds() - tStart.getMilliseconds();
return("Elapsed time = " + (t / 1000.0));
}
function setDivValue(s) {
var adiv = document.getElementById("adiv");
adiv.innerHTML = s;
}
function doIt() {
if (!zXmlHttp.isSupported()) {
setDivValue("XMLHttp not supported");
return;
}
var oXmlHttp = zXmlHttp.createRequest();
oXmlHttp.open("get", window.location.pathname, false);
oXmlHttp.onreadystatechange = function () {
if (oXmlHttp.readyState == 4) {
tStop = new Date();
if (oXmlHttp.status != 200) {
setDivValue("Error " + oXmlHttp.status + " while loading: " + oXmlHttp.reponseText);
} else {
setDivValue(getTimeElapse());
if (document.getElementById("cb").checked) {
var s = oXmlHttp.responseText.substring(0, 195);
alert(s + "...");
}
}
}
}
tStart = new Date();
oXmlHttp.send(null);
}
</script>
</head>
<body>
<button onclick="doIt();">Find Latency to Load This Page</button>
<input type="checkbox" id="cb"/>
<br />
<div id="adiv"> </div>
</body>
</html>