>> KYSCORP.COM TUTORIALS >> Javascript Tutorials
Loading Time
In the following tutorial we will learn how to display the page's loading time in the status bar of your navigator, you have to insert the following code between the <head> and </head> tags:
<script language="javascript">
NavName = navigator.appName.substring(0,3);
NavVersion = navigator.appVersion.substring(0,1);
if (NavName != "Mic" || NavVersion>=4)
{
start = new Date;
start = start .getTime();
}
function loadtime()
{
if (NavName != "Mic" || NavVersion>=4)
{
end = new Date;
end = end.getTime();
seconds = (end-start )/1000;
if (seconds>1)
{
window.status='Page loaded in ' + seconds + ' seconds.';
}
else
{
window.status='Page loaded in ' + seconds + ' second.';
}
}
}
</script>
NavName = navigator.appName.substring(0,3);
NavVersion = navigator.appVersion.substring(0,1);
if (NavName != "Mic" || NavVersion>=4)
{
start = new Date;
start = start .getTime();
}
function loadtime()
{
if (NavName != "Mic" || NavVersion>=4)
{
end = new Date;
end = end.getTime();
seconds = (end-start )/1000;
if (seconds>1)
{
window.status='Page loaded in ' + seconds + ' seconds.';
}
else
{
window.status='Page loaded in ' + seconds + ' second.';
}
}
}
</script>
The following code must be inserted inside the <body> tag this way :
<body onLoad="loadtime()">
Carpe diem people...