Help - page, rendering time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fabius

    Help - page, rendering time

    Hi,

    I want display page rendering time.

    Is correct this code? :

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

    <script language="JavaS cript">
    function displayRenderin gTimestamp() {
    var timestampb=new Date;

    alert (timestampb.get Time() - timeInit );
    }
    </script>
    </head>
    <body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0 "
    marginwidth="0" marginheight="0 " onLoad="display RenderingTimest amp()">

    Or must be implemented init function to set start timestamp?

    Thanks for any suggestion,
    Fabio
  • Mick White

    #2
    Re: Help - page, rendering time

    fabius wrote:
    [color=blue]
    > Hi,
    >
    > I want display page rendering time.
    >
    > Is correct this code? :
    >
    > <html>
    > <head>
    > <SCRIPT>
    > var timestampa =new Date;
    > var timeInit = timestampa.getT ime();
    > </SCRIPT>
    >
    > <script language="JavaS cript">
    > function displayRenderin gTimestamp() {
    > var timestampb=new Date;
    >
    > alert (timestampb.get Time() - timeInit );
    > }
    > </script>
    > </head>
    > <body topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0 "
    > marginwidth="0" marginheight="0 " onLoad="display RenderingTimest amp()">
    >
    > Or must be implemented init function to set start timestamp?[/color]

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

    <SCRIPT type="text/javascript">
    timeInit = new Date().getTime( );
    function displayRenderin gTimestamp() {
    alert (new Date().getTime( ) - timeInit );
    }
    onload=displayR enderingTimesta mp; //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.(Automa tic type conversion)
    Mick

    Mick

    Comment

    Working...