Created
June 17, 2011 06:55
-
-
Save ambar/1030979 to your computer and use it in GitHub Desktop.
如何保持chrome扩展选项tab唯一
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 打开chrome扩展选项tab | |
var option_url = chrome.extension.getURL('options/index.html'); | |
chrome.tabs.getAllInWindow(null,function(tabs){ | |
var option_tab = tabs.filter(function(t) { return t.url === option_url }); | |
if(option_tab.length){ | |
// 已经打开,直接激活 | |
chrome.tabs.update(option_tab[0].id,{selected:true}); | |
}else{ | |
chrome.tabs.create({url:option_url,selected:true}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment