Problem refreshing Chrome
I'm attem开发者_如何学运维pting to refresh the current tab using my chrome extension. Why isn't the following working?
var url = window.location.href;
chrome.tabs.getSelected(null, function(tab{
var id=tab.id
}))
chrome.tabs.getSelected(function(tab){
chrome.tabs.update(id, {url: url});
});
At first, I would combine these two functions into one. In the first call to chrome.tabs.getSelected
you missplaced some parentheses: function(tab{
Because there is a )
missing there, you have two )
at the end instead of one.
var url = window.location.href;
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.update(tab.id, {url: url});
})
Why not just do instead, no need for window.location.href:
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.update(tab.id, {url: tab.url});
})
精彩评论