I am trying to create a javascript function which returns the last modified date of a remote url which it recieves. I have tried many different methods, none of which seem to work. The following code seems like it may be close, but unfortunately doesnt work.
function getlastmod(url) {
var req = new XMLHttpRequest();
req.open("GET", url, false);
req.getResponseHeader("Last-Modified");
req.send("");
return req.responseText;
}
The function will be used in a chrome extension that I am making.
Thanks for any help-Josh
Some issues:
Try this:
This requires your extension to ask for the right permissions (because you are doing cross-origin xhr) as well as the server to send the header.