gpt4 book ai didi

javascript - 如何使用 Jquery/Javascript 计算 Asp.net 页面的加载时间?

转载 作者:行者123 更新时间:2023-11-30 08:13:12 25 4
gpt4 key购买 nike

我正在开发一个 Web 应用程序,因为我想检查每个页面的加载时间或控制加载时间..

加载整个页面内容需要多少时间?
我想以微秒/秒计算 asp.net 页面加载时间,

我怎么知道使用 Javascript/Jquery?

最佳答案

以下脚本可以帮助您;

<SCRIPT LANGUAGE="JavaScript">
//calculate the time before calling the function in window.onload
beforeload = (new Date()).getTime();
function pageloadingtime()
{

//calculate the current time in afterload
afterload = (new Date()).getTime();
// now use the beforeload and afterload to calculate the seconds
secondes = (afterload-beforeload)/1000;
// If necessary update in window.status
window.status='You Page Load took ' + secondes + ' seconde(s).';
// Place the seconds in the innerHTML to show the results
document.getElementById("loadingtime").innerHTML = "<font color='red'>(You Page Load took " + secondes + " seconde(s).)</font>";

}

window.onload = pageloadingtime;
</SCRIPT>

引用自:http://www.dreamincode.net/code/snippet1908.htm

如果你只想查看时间,可以使用显示执行时间的 firefox 的 Firebug。像这样的 enter image description here

关于javascript - 如何使用 Jquery/Javascript 计算 Asp.net 页面的加载时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7512982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com