1 Display Page Load Time Mon Mar 29, 2010 2:03 am
Guest
Guest
Display Page Load Time Display page loading time with JavaScript and HTML |
Hi Guest! We are going to write a code which will show the page load time of a particular page. It contains JavaScript as well as HTML. First of all, we get the current time by using Date() function and store its value in the variable 'ladestart'.
Then we initiate a function called 'ladezeit' in which we get the value of current time again and store its value in variable 'current'.
Now, we need to get the time in seconds. For that we'll use the getTime() function which will calculate time in milliseconds. We find out the difference between time before and after execution of the function 'ladezeit'. The time difference is stored in the variable 'dtime'.
The time difference we found is in milliseconds. To conver it into seconds we'll divide it by 1000.
Now, we have got the page load time. We just need to display it some where on the page. For that, we'll use the 'innerHTML' method. We'll display the page load time in a container have id='Ladezeit-Anzeige'.
Now comes the HTML part. We have to make the function to be executed when the main body loads, so we'll add this to our <body> tag...
And yes, we need to create a <div> with id 'Ladezeit-Anzeige' where the page load time will be displayed.
Its done Here is the full code...
Updated By ankillien |
Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators. |