admin管理员组文章数量:1291111
I use
chrome.tabs.create({url:"URL here"})
to open a new tab in my LRG. To this URL I want to append the version number of the extension, which is specified in the manifest.json
file:
"version": "1.2",
How can I access the version number in javascript at the time of creating the new tab?
I use
chrome.tabs.create({url:"URL here"})
to open a new tab in my LRG. To this URL I want to append the version number of the extension, which is specified in the manifest.json
file:
"version": "1.2",
How can I access the version number in javascript at the time of creating the new tab?
Share Improve this question asked Jun 22, 2011 at 6:53 LazerLazer 95k115 gold badges290 silver badges368 bronze badges3 Answers
Reset to default 7Try in your extension:
chrome.app.getDetails().version
I don't know why it's not among other APIs but it works in my Chrome 13 beta. Rather test it in older versions of Chrome :).
EDIT: It's probably a little buggy
You can fetch your own manifest and the version by using the following:
var url = chrome.extension.getURL("manifest.json");
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(e) {
if(xhr.readyState == 2 && xhr.status == 200) {
var manifest = JSON.parse(xhr.responseText);
alert("Version: " + manifest.version);
}
};
xhr.open("GET", url);
xhr.send();
Once you have the version number you can do your tab stuff that you need to do.
I don't have enough rep to ment but in regard to Kinlan's XMLHttpRequest answer:
I found this very useful, but I did notice it should wait for readyState == 4 (not 2).
Worked great for me and seems like it should be robust.
本文标签: javascriptHow to reference the version information in a Google Chrome extensionStack Overflow
版权声明:本文标题:javascript - How to reference the version information in a Google Chrome extension? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741506967a2382378.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论