By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,737 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

Help - page, rendering time

P: n/a
Hi,

I want display page rendering time.

Is correct this code? :

<html>
<head>
<SCRIPT>
var timestampa =new Date;
var timeInit = timestampa.getTime();
</SCRIPT>

<script language="JavaScript">
function displayRenderingTimestamp() {
var timestampb=new Date;

alert (timestampb.getTime() - timeInit );
}
</script>
</head>
<body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0"
marginwidth="0" marginheight="0" onLoad="displayRenderingTimestamp()">

Or must be implemented init function to set start timestamp?

Thanks for any suggestion,
Fabio
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
fabius wrote:
Hi,

I want display page rendering time.

Is correct this code? :

<html>
<head>
<SCRIPT>
var timestampa =new Date;
var timeInit = timestampa.getTime();
</SCRIPT>

<script language="JavaScript">
function displayRenderingTimestamp() {
var timestampb=new Date;

alert (timestampb.getTime() - timeInit );
}
</script>
</head>
<body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0"
marginwidth="0" marginheight="0" onLoad="displayRenderingTimestamp()">

Or must be implemented init function to set start timestamp?


Your code should do what you want, but I'd use "new Date()"

<SCRIPT type="text/javascript">
timeInit = new Date().getTime();
function displayRenderingTimestamp() {
alert (new Date().getTime() - timeInit );
}
onload=displayRenderingTimestamp; //in milliseconds
</script>

And you really don't need to use the Date object's "getTime()" method,

dateObj1-dateObj2 will yield the difference in milliseconds between two
valid date objects.(Automatic type conversion)
Mick

Mick
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.