Thursday, June 6, 2024
10
rated 0 times [  16] [ 6]  / answers: 1 / hits: 28124  / 13 Years ago, thu, june 16, 2011, 12:00:00

I'm writing a Chrome extension, I need to get my extension's id in my code, so I don't need to change it manually every time. How can I do this?


More From » google-chrome-extension

 Answers
41

You can get it like this (no extra permissions required) in two different ways:




  1. Using runtime api: var myid = chrome.runtime.id;


  2. Using i18n api: var myid = chrome.i18n.getMessage(@@extension_id);




but you don't need it for opening pages, as chrome.tabs.create() (and some others) understand relative paths.



So to open index.html from your extension folder you should just use:



chrome.tabs.create({url: index.html});

[#91676] Wednesday, June 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adrienkeithr

Total Points: 503
Total Questions: 126
Total Answers: 110

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
;