ste-m wrote:
Quote:
Hi there,
>
I was wanting to calculate how long my web pages take to load, and to insert
this time into my HTML source code (not visible from the browser, but only
in source view) as a HTML comment.
>
I've found a JavaScript that does this here:
http://www.twohootssoftware.co.uk/code/loadtimejs.html
>
<script language="javascript" type="text/javascript">
Drop the language attribute, keep type.
Quote:
var now = new Date();
var startTime = now.getTime()
or:
var startTime = new Date().getTime();
Script elements must be inside either a head or body element, they
can't be outside the HTML element. Error correction will (probably)
move them back inside.
Quote:
<!-- <html>
...... put your code here.....
</html>
//-->
<script language="javascript" type="text/javascript">
now = new Date();
var endTime = now.getTime();
alert("Time taken to load page : " + ((endTime - startTime)/1000)+"
seconds");
</script>
>
Except that it puts the time in a popup window. I tried changing the code
to print the value as 'document.write' instead of 'alert' but I can't get
this code to stay hidden in the browser and only visible within the HTML
source code.
The source code is the source code, not the generated code. You can
look at the innerHTML property, or use a DOM or generated code
inspector (there's one called "savegenpage" for Firefox) to see the
generated page.
Quote:
Can someone let me know how I can alter the above script to do this?
You can't.
--
Fred