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?
Try 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With