简体   繁体   English

我正在使用javascript计算页面加载时间。 但不幸的是,我得到的是负值。

[英]I am calculating page load time using javascript. But unfortunately I am getting it in negative value.

I am calculating page load time using JavaScript. 我正在使用JavaScript计算页面加载时间。 But unfortunately I am getting it in negative value. 但不幸的是,我得到的是负值。

var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;

Output: -51236723 输出:-51236723

Can you try with this @Shahdab Aalam Saifi 你可以尝试这个@Shahdab Aalam Saifi

var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
var pageloadtime = (loadTime/1000) ; //returns the seconds

Hope this helps 希望这可以帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 5秒钟后,我无法执行引导模式,仅使用javascript在页面上弹出。 - I am unable to execute a bootstrap modal after 5 seconds to pop up on the page using only javascript. 我正在使用这个javascript来“未定义”。 为什么? - I am geting “undefined” with this javascript. Why? 我正在尝试使用JavaScript创建一个计算器。 - I am trying to create a calculator with javascript. 从下拉列表中获取价值。 我正在尝试使用 Javascript 获取下拉列表的值。 它不断返回第一个选项的值 - Getting value from dropdown list. I am trying to get value of dropdown list using Javascript. It keep returning the value of the first option 每次尝试使用随机背景图像创建主页时。 使用HTML和JavaScript。 我究竟做错了什么? - Trying to Create Homepage with Random Background Image Each Time it is Accessed. Using HTML and JavaScript. What am I doing wrong? 我在JavaScript中发现方法未找到错误。 但我已经定义了 - I am getting method not found error in Javascript. But I have defined it 如何在Array JavaScript中引用元素的位置。 (我没有得到预期的结果) - How do I refer position of an element in Array javascript. (I am not getting the expected result) 在不同的页面上使用相同的 JavaScript,为什么会出现错误? - Using the same JavaScript on a different page, why am I getting an error? JavaScript新手。 我试图将单选按钮的值作为javascript函数中对象的名称传递 - new to javascript. I am trying to pass the value of a radio button as the name of an object in a javascript function 我是 JavaScript 的新手。 请帮我进行 javascript 验证 - I am new to JavaScript. please help me for javascript validation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM