开发者

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});
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜