chrome extension API for refreshing the page

The API for chrome.tabs.getSelected(), which the accepted answer uses, has been deprecated. You should instead get the current tab and reload it using something like the following:

chrome.tabs.query({active: true, currentWindow: true}, function (arrayOfTabs) {
    var code = 'window.location.reload();';
    chrome.tabs.executeScript(arrayOfTabs[0].id, {code: code});
});

Or perhaps:

chrome.tabs.query({active: true, currentWindow: true}, function (arrayOfTabs) {
    chrome.tabs.reload(arrayOfTabs[0].id);
});

I had no real luck with the second version, though other answers seem to suggest it should work. The API seems to suggest that, too.


I recommend using chrome.tabs.executeScript to inject javascript that calls window.location.reload() into the current tab. Something like:

chrome.tabs.getSelected(null, function(tab) {
  var code = 'window.location.reload();';
  chrome.tabs.executeScript(tab.id, {code: code});
});

Reference here


I think what you're looking for is:

chrome.tabs.reload(integer tabId, object reloadProperties, function callback)

Check out tabs API() documentation for more information.