Client code:
Add the initial time in the Head part of the page
Copy codeThe Code is as follows:
<Script language = javascript>
Var t1 = new Date (). getTime ();
</Script>
Add in Body
Copy codeThe Code is as follows:
<Script language = "JavaScript">
Window. onload = function ()
{
Document. getElementById ("TimeShow"). innerHTML = "loading this page time" + (new Date (). getTime ()-t1) + "millisecond ";
}
</SCRIPT>
Insert a tag ID TimeShow in the area to be displayed.
<Div id = "TimeShow"> </div>
Server code syntax:
Copy codeThe Code is as follows:
Protected DateTime dt;
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected override void OnPreInit (EventArgs e)
{
Dt = DateTime. Now;
Base. OnPreInit (e );
}
Protected override void OnLoadComplete (EventArgs e)
{
Base. OnLoadComplete (e );
TimeSpan ts = DateTime. Now-dt;
Response. Write ("when loading the page:" + ts. TotalMilliseconds );
}