2 Replies - 1506 Views - Last Post: 25 April 2012 - 09:14 AM

#1 deepamanohar  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-March 08

Calculating Page Loading Time

Posted 21 April 2008 - 10:32 PM

Description: Calculating the page loading time in javascript on window.onload and displaying the results in div
<head>
<title>Calculating Page Loading Time</title>
<script LANGUAGE="Javascript">
//calculate the time before calling the function in window.onload
beforeload = (new Date()).getTime();
function pageloadingtime()
{

	 //calculate the current time in afterload 
	afterload = (new Date()).getTime();
	 // now use the beforeload and afterload to calculate the seconds
	secondes = (afterload-beforeload)/1000;
	 // If necessary update in window.status
	window.status='You Page Load took  ' + secondes + ' seconde(s).';
	 // Place the seconds in the innerHTML to show the results
	document.getElementById("loadingtime").innerHTML = "<font color='red'>(You Page Load took " + secondes + " seconde(s).)</font>";
	
}
  
window.onload = pageloadingtime;
</SCRIPT>
</head>
<body >
<table border width=40%>
<tr><td colspan=2><strong>Page Loading Script</strong></td></tr>
<TR>                 <TH> sample </TH> <TH> test</TR>
<TR ALIGN="left">    <TH> Hi  1<BR>bloop </TH> <TH> Head 2 </TR>
<TR VALIGN="bottom"> <TH> test 1<BR>bloop </TH> <TH> Head 2 </TR>
<TR>                 <TH> hi 1<BR>bloop </TH> <TH> Head 2 </TR>
<TR ALIGN="center">  <TD> y<BR>aaaa     </TD> <TD> 4.23   </TR>
<TR ALIGN="right">   <TD> new     </TD> <TD> test</TR>
</table>
<p><div id="loadingtime"></div></p>
</body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: Calculating Page Loading Time

#2 ambipur  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 15-April 12

Re: Calculating Page Loading Time

Posted 15 April 2012 - 01:37 PM

Hi, I am modifying my page with a javascript. When a button is pressed, the sorce of some images is completed and the download of them starts. But this case the body onload event is not triggered. Any idea how to inwoke the function to measure the download time of the images? The browser's status bar displays correctly when it is ready. Thanks in advance!
Was This Post Helpful? 0
  • +
  • -

#3 EagleEye  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-April 12

Re: Calculating Page Loading Time

Posted 25 April 2012 - 09:14 AM

Hi deepamanohar, Thank you for the javascript! I have tried so many solutions now(php & javascript) and nothing works on this f...... Internet, except for the one you have here. It works perfect! Thanks man!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1