...

View Full Version : Page Loading Time



mark87
12-30-2004, 07:30 PM
I downloaded a script - http://www.a1javascripts.com/time_related/pageloadingtime/pageloadingtime.html

I've also put it below -


<script Language="JavaScript">
var from_time = new Date();
from_time = from_time.getTime();
function show_loading_time()
{
var to_time = new Date();
to_time = to_time.getTime();
var secs = (to_time - from_time) /1000;
}
</script>

I would like to write the text in part of the page but I can't do it...

I tried - <script>document.write(secs)</script> but it says secs is undefined.

Brandoe85
12-30-2004, 07:36 PM
Try putting an onload event calling your function, also put document.write(secs) in your function.
<body onload="show_loading_time();">

mark87
12-30-2004, 07:52 PM
I've done the onload etc, but I want the time to be written in a specific place.

Brandoe85
12-30-2004, 07:55 PM
I guess i'm confused, if you have it in a function like you do, you'll have to call the function somehow. Maybe you can explain in more detail. :)

mark87
12-30-2004, 08:14 PM
OK, the function goes in the head, when the onLoad event is triggered, the function is run calculating the page load time. I wish to display the output of that (secs) somewhere in the text in my page. :)

Brandoe85
12-30-2004, 09:00 PM
I see, well then your not going to want to use document.write(), you're gonna want to use a div, or something of that matter, and write the seconds in there or you can do it like the example page you posted up where they have it in a text box.

mark87
12-30-2004, 09:30 PM
Hmm, I'd rather not use a text box as I want it in the actual text.... there must be a way? :S I'll keep trying!

Brandoe85
12-30-2004, 09:33 PM
.....
I see, well then your not going to want to use document.write(), you're gonna want to use a div, or something of that matter



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum