Get the timestamp of loaded page

好久不见. 提交于 2019-12-19 05:56:13

问题


Is there a way in javascript or in chrome extension API to instantly (without saving the timestamp during the loading time) get the timestamp of when the DOM of the page was loaded in Chrome?


回答1:


You can use the performance.timing object (implemented by all modern browsers, except Safari) to get all kinds of different timestamps.

You need to see for yourself what timestamp would be most appropriate for you. "when the page was loaded" is quite a vague description. Otherwise, be more specific.

If you don't to go through the trouble of having a Chrome content script communicate with a Chrome background page, you can also use the Chrome webNavigation API. However this only exposes events, so you'd be responsible for saving the time when this event is fired (for each page).




回答2:


Click on Javascript Console from Tools menu.

Then enter the following:

 javascript:alert(document.lastModified)



回答3:


Current document timestamp:

var currentDocumentTimestamp = new Date(document.lastModified).getTime();


来源:https://stackoverflow.com/questions/22098117/get-the-timestamp-of-loaded-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!