Le_Coeur
Le_Coeur

Reputation: 1541

Get the timestamp of loaded page

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?

Upvotes: 12

Views: 9408

Answers (3)

Eduardo Cuomo
Eduardo Cuomo

Reputation: 18937

Current document timestamp:

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

Upvotes: 2

Myrne Stol
Myrne Stol

Reputation: 11438

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).

Upvotes: 19

codehitman
codehitman

Reputation: 1188

Click on Javascript Console from Tools menu.

Then enter the following:

 javascript:alert(document.lastModified)

Upvotes: 6

Related Questions